/**
 * Created by Administrator on 2017/6/7.
 */

angular.module('zds.controller', ['mobiscroll-datetime'])


    //登录注册控制器模块 开始------------------------------------------------
    .controller('shouHouZhuangTaiListCtrl',['$scope','$http','$state', function($scope,$http,$state) {
        //localStorage.setItem('loginIf',angular.toJson({loginIf:'ddd'}));
        var params = {};
        params.method = "refund.order.refund";
        var p_params = {
            return_id:""
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function(data) {
                $scope.data = data.data;
                if(data.message=="无退款单"){
                    $('.wddd_main_box').css({
                        'background':"url('image/no_order.jpg')",
                        'backgroundSize':'100%'
                    })
                }
                $scope.tiaozhuan=function(num){
                  $state.go("tuiKuanShenQing",{
                    id:num
                  })
                };
            });
    }])
    ////登录控制器
    .controller('loginCtrl',['$scope','$http','$state', function($scope,$http,$state) {
        //localStorage.setItem('loginIf',angular.toJson({loginIf:'ddd'}));

    }])
    .controller('huoDongTuiJianYeCtrl',['$scope','$http','$state',"$stateParams", function($scope,$http,$state,$stateParams) {
      var articleid = $stateParams.id;
        var params = {};
        params.method = "article.get.activity";
        var p_params = {
            id:articleid
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function(data) {
                $scope.data = data;
                $(".product_main_img_container").html(data.data.content);
            });
    }])

    //最后登录控制器
    .controller('login0Ctrl',['$scope','$http','$state', function($scope,$http,$state) {
        var params = {};
        params.method = "member.is.login";
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (1 == data.status) {
                    $state.go('pinPaiQuan');
                }
            });
    }])

    //用户登录控制器
    .controller('userLoginCtrl',['$rootScope','$scope','$http','$state', function($rootScope,$scope,$http,$state) {
        var params = {};
        params.method = "member.is.login";
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (1 == data.status) {
                    $state.go('pinPaiQuan');
                }
            });

        $scope.username = {kw: ''};//用户手机号码
        $scope.password = {kw: ''};//用户密码
        //密码睁开眼显示内容
        $scope.eyePasswordState = false;
        $scope.eyePasswordOpen = function(){
            $scope.eyePasswordState = !$scope.eyePasswordState;
            var loginPwdText = document.getElementById('loginPwdText');
            if($scope.eyePasswordState){
                loginPwdText.setAttribute('type','text');
            }else{
                loginPwdText.setAttribute('type','password');
            }
        };

        //调用登录接口
        $scope.login = function () {
            var params = {};
            params.method = "member.member.login";
            var p_params = {
                username: $scope.username.kw,
                password: $scope.password.kw
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    if (data.status == 1) {
                        localStorage.setItem('loginName',angular.toJson({username:$scope.username.kw}));
                        $rootScope.goLoginURL();
                    } else {
                       alert(data.message);
                    }
                });
        };
    }])

    //注册控制器
    .controller('registerCtrl',['$scope','$http','$state','$interval', function($scope,$http,$state,$interval) {
        var params = {};
        params.method = "member.is.login";
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (1 == data.status) {
                    $state.go('pinPaiQuan');
                }
            });

        $scope.showZhuCeYeMian = false;//显示注册协议
        $scope.gaiClass = false;//为同意按钮天天加class
        $scope.gaiClassT = function(){
            $scope.gaiClass = true;
        };
        $scope.ZhuCeYeMianCtrl = function(){
            $scope.showZhuCeYeMian = !$scope.showZhuCeYeMian;
        };
        $scope.showYanZhengMa = true;//控制验证码显示与隐藏
        $scope.registerTime = 60;
        var pattern = /^1\d{10}$/;//验证手机号
        $scope.username = {kw:''};//接收用户手机号码
        $scope.registerMa = {kw:''};//接收验证码
        $scope.password = {kw:''};//接收用户密码
        $scope.rePassword = {kw:''};//接收用户确认密码

        //密码睁开眼显示内容
        $scope.eyePasswordState = false;
        $scope.eyePasswordOpen = function(){
            $scope.eyePasswordState = !$scope.eyePasswordState;
            var pwdText = document.getElementById('pwdtext');
            if($scope.eyePasswordState){
                pwdText.setAttribute('type','text');
            }else{
                pwdText.setAttribute('type','password');
            }
        };
        //确认密码睁开眼显示内容
        $scope.rePasswordState = false;
        $scope.rePasswordOpen = function(){
            $scope.rePasswordState = !$scope.rePasswordState;
            var rePsd = document.getElementById('rePsd');
            if($scope.rePasswordState){
                rePsd.setAttribute('type','text');
            }else{
                rePsd.setAttribute('type','password');
            }
        };
        //检测用户是否存在接口调用
        $scope.checkUser = function(){
            $scope.showErro = true;
            if(pattern.test($scope.username.kw)){
                var params = {};
                params.method = "member.check.vip";
                var p_params = {
                    mobile:$scope.username.kw
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if (data.status == 1) {
                            $scope.userErro = data.message;
                            setTimeout(function(){
                                $scope.$apply(function(){
                                    $scope.showErro = false;
                                })
                            },2000)

                        } else if(data.status == -1){
                            $scope.userErro = data.message;
                            setTimeout(function(){
                                $scope.$apply(function(){
                                    $scope.showErro = false;
                                })
                            },2000)

                        }
                    });
            }else{
                $scope.userErro = '请输入正确的手机';
                    setTimeout(function(){
                        $scope.$apply(function(){
                            $scope.showErro = false;
                        })
                    },2000)

            }
        };

        //验证接口调用
        $scope.yan = function(){
            if(pattern.test($scope.username.kw)){
                $scope.showYanZhengMa = !$scope.showYanZhengMa;
                var time1 = $interval(function(){
                    $scope.registerTime--;
                    if($scope.registerTime==0){
                        $scope.showYanZhengMa = !$scope.showYanZhengMa;
                        $interval.cancel(time1);
                        $scope.registerTime = 60;
                    }
                },1000);
                var params = {};
                params.method = "member.get.yan";
                var p_params = {
                    mobile:$scope.username.kw
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if (data.status == 1) {

                        } else {

                        }
                    });
            }
        };

        //注册接口调用
        $scope.register = function(){
            if($scope.password.kw != $scope.rePassword.kw){
                $scope.showErro = true;
                $scope.userErro = '2次输入的密码不一致';
                setTimeout(function(){
                    $scope.$apply(function(){
                        $scope.showErro = false;
                    })
                },2000);
                return false;
            }

            var params = {};
            params.method = "member.member.register";
            var p_params = {
                mobile:$scope.username.kw,
                yan:$scope.registerMa.kw,
                password:$scope.password.kw,
                re_password:$scope.rePassword.kw
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function(data) {
                    if (data.status == 1) {
                        $state.go('userLogin');
                    } else {
                        // //.log(data.message);
                    }
                });
        };
        //$scope.showErro = false;
    }])
    //忘记密码控制器
    .controller('forgetPasswordCtrl',['$scope','$http','$state','$interval', function($scope,$http,$state,$interval){
        $scope.showYanZhengMa = true;//控制验证码显示与隐藏
        $scope.registerTime = 60;
        var pattern = /^1\d{10}$/;//验证手机号
        $scope.username = {kw:''};//接收用户手机号码
        $scope.registerMa = {kw:''};//接收验证码
        $scope.password = {kw:''};//接收用户密码
        $scope.rePassword = {kw:''};//接收用户确认密码

        //密码睁开眼显示内容
        $scope.eyePasswordState = false;
        $scope.eyePasswordOpen = function(){
            $scope.eyePasswordState = !$scope.eyePasswordState;
            var pwdText = document.getElementById('pwdtext');
            if($scope.eyePasswordState){
                pwdText.setAttribute('type','text');
            }else{
                pwdText.setAttribute('type','password');
            }
        };
        //确认密码睁开眼显示内容
        $scope.rePasswordState = false;
        $scope.rePasswordOpen = function(){
            $scope.rePasswordState = !$scope.rePasswordState;
            var rePsd = document.getElementById('rePsd');
            if($scope.rePasswordState){
                rePsd.setAttribute('type','text');
            }else{
                rePsd.setAttribute('type','password');
            }
        };
        //检查用户是否存在
        $scope.checkUser = function(){
            $scope.showErro = false;
            if(pattern.test($scope.username.kw)){
                var params = {};
                params.method = "member.check.vip";
                var p_params = {
                    mobile:$scope.username.kw
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if (data.status == 1) {
                            $scope.showErro = true;
                            $scope.userErro = '用户不存在';
                            setTimeout(function(){
                                $scope.$apply(function(){
                                    $scope.showErro = false;
                                })
                            },2000)
                        } else if(data.status == -1){
                            $scope.showErro = false;
                        }
                    });
            }else{
                $scope.showErro = true;
                $scope.userErro = '请输入正确的手机';
                setTimeout(function(){
                    $scope.$apply(function(){
                        $scope.showErro = false;
                    })
                },2000)
            }
        };
        //验证接口调用
        $scope.yan = function(){
            if(pattern.test($scope.username.kw)){
                var params = {};
                params.method = "member.check.vip";
                var p_params = {
                    mobile:$scope.username.kw
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if (data.status == 1) {
                            $scope.userErro = '用户不存在';

                        } else if(data.status == -1){
                                $scope.showYanZhengMa = !$scope.showYanZhengMa;
                                var time1 = $interval(function(){
                                    $scope.registerTime--;
                                    if($scope.registerTime==0){
                                        $scope.showYanZhengMa = !$scope.showYanZhengMa;
                                        $interval.cancel(time1);
                                        $scope.registerTime = 60;
                                    }
                                },1000);
                                var params = {};
                                params.method = "member.get.yan";
                                var p_params = {
                                    mobile:$scope.username.kw,
                                    type:1
                                };
                                params.params = JSON.stringify(p_params);
                                $http.get(baison.get_url('api/', params))
                                    .success(function(data) {
                                        if (data.status == 1) {

                                        } else {
                                            // //.log(data.message);
                                        }
                                    });
                            }

                    });
            }else{
                $scope.showErro = true;
                $scope.userErro = '请输入正确的手机';
                setTimeout(function(){
                    $scope.$apply(function(){
                        $scope.showErro = false;
                    })
                },2000)
            }
        };

        //修改密码接口调用
        $scope.register = function(){

            if($scope.password.kw != $scope.rePassword.kw){
                $scope.showErro = true;
                $scope.userErro = '2次输入的密码不一致';
                setTimeout(function(){
                    $scope.$apply(function(){
                        $scope.showErro = false;
                    })
                },2000);
                return false;
            }

            var params = {};
            params.method = "member.forget.password";
            var p_params = {
                username:$scope.username.kw,
                password:$scope.password.kw,
                re_password:$scope.rePassword.kw,
                yan:$scope.registerMa.kw
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function(data) {
                    if (data.status == 1) {
                        $state.go('userLogin');
                    } else {
                        // //.log(data.message);
                    }
                });
        };
    }])


    //登录注册模块控制器  结束-------------------------------------------------------------


    //首页模块控制器  开始------------------------------------------------------------------

    //品牌圈控制器
    .controller('pinPaiQuanCtrl',['$scope','$rootScope','$http','$state','$swipers','$stateParams','$timeout', function($scope,$rootScope,$http,$state,$swipers,$stateParams,$timeout) {
          setTimeout(function(){
            localStorage.setItem('shopId',angular.toJson({data:""}));
          },100);

          $scope.goto = function(url){
              var urls = url.split('#');
              var path = urls[1].split('/');

              $state.go(path[1],{
                  id:path[2]
              })
          };

        /*if (typeof($rootScope.enter) == "undefined" && typeof(api)=='undefined') {
            apiready = function() {

                if(typeof(api.connectionType) == 'wifi'){
                    alert('程序检测到未开启网络！');
                }
            }
        }*/
          
        $scope.check_version = function(){
            var deviceId = api.deviceId;
            var appVersion = api.appVersion;
            var params = {};
            params.method = "article.device.guide";
            var p_params = {
                deviceId: deviceId,
                appVersion: appVersion
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function(data) {
                    $rootScope.enter = 1;
                    if( data.status==1 && data.data==1){
                        $scope.showGuide = true;
                        var mySwiper = new Swiper ('.guide-swiper', {
                            autoplay: 0,
                            // 如果需要分页器
                            // pagination: '.swiper-pagination',
                            // paginationClickable: true,
                        });

                        // $state.go('guide');
                    }else{
                        $scope.showGuide = false;
                    }
                    $scope.showGuideLoad = false;
                    //alert(JSON.stringify(data));
                });
        };

        $scope.loadGuide = function(){
            $scope.showGuideLoad = true;
            $scope.showGuide = true;

            if (typeof($rootScope.enter) == "undefined" && typeof(api)=='undefined') {
                apiready = function() {
                    $scope.check_version();
                }
                if(typeof(api)=='undefined'){
                    $scope.showGuideLoad = false;
                    $scope.showGuide = false;
                }
            } else {
                $scope.showGuideLoad = false;
                $scope.showGuide = false;
            }
        };

        $scope.guide_out = function(){
            $scope.showGuide = false;
            // $state.go('pinPaiQuan');
        };



        $scope.showFooterA = true;
        $scope.showFooterB = false;
        $scope.showFooterC = false;
        $scope.showFooterD = false;

        $scope.hdbol=true;
        //控制跳转
        $scope.goUrl = function(cat_id,article_id){
            if(cat_id == '22'){
                $state.go('zhuBaoXueTang',{
                    id:article_id
                })
            }else if(cat_id == '24'){
                $state.go('zhuBaoDaPei',{
                    id:article_id
                })
            }
        };
        var PinPaiBanner = function () {
            var params = {};
            params.method = "article.get.pinpai.banner";
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    alert('7');
                    if (data.status == 1) {
                        $scope.banner = data.data;
                        //等遍历完成再执行
                        $scope.repeatFinish = function(){
                            $scope.swipers = $swipers.swp('.swiper-container',false,5000,1,1,'.swiper-pagination',null,null,0,false,function(){
                                return;
                            });
                        };
                    } else {
                        // //.log(data.message);
                    }
                });
        };
        //消息中心
        var MessageCenter=function () {
            var params = {};
            params.method = "article.get.my.comment.count";
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    alert('8');
                    if (data.status == 1) {
                        $scope.lengdata = data.data.count;
                        if($scope.lengdata == 0) $scope.hdbol = true; else $scope.hdbol = false;
                    } else {
                        $scope.hdbol = true;
                    }
                });
        };

        var ArticleCategory = function () {
            var params = {};
            params.method = "article.get.category";
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    alert('9');
                    if (data.status == 1) {
                        $scope.data = data.data;
                        $scope.run1 = function($event){
                            if($event.target.nodeName == 'IMG' || $event.target.nodeName == 'DIV'){
                                var chuanId = $event.target.parentNode;
                                var chuanId1 = chuanId.getAttribute('id');
                            }else if($event.target.nodeName == 'P'){
                                var chuanId = $event.target.parentNode.parentNode;
                                var chuanId1 = chuanId.getAttribute('id');
                            }
                            if(chuanId1 == 22){
                                localStorage.setItem('zhuBaoDaPei',angular.toJson({data:'22'}));
                                $state.go('zhuBaoDaPeiList');
                            }else if(chuanId1 == 23){
                                //localStorage.setItem('sheJiShi',angular.toJson({data:'23'}));
                                $state.go('sheJiShiMoKuai');
                            }else if(chuanId1 == 24){
                                localStorage.setItem('zhuBaoXueTang',angular.toJson({data:'24'}));
                                $state.go('zhuBaoXueTangList');
                            }
                        };
                    } else {
                        // //.log(data.message);
                    }
                });
        };
        //调取热门文章
        var ArticleSelect=function () {
            var params = {};
            params.method = "article.get.select";
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    alert('10');
                    if (data.status == 1) {
                        $scope.data1 = data.data;

                        $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
                            for(var i = 0;i<data.data.length;i++){
                                if($scope.data1[i].is_zan == 0){
                                    $(".ppj_like_box_flxe-xin").eq(i).attr("src","image/heixin.png");
                                }else{
                                    $(".ppj_like_box_flxe-xin").eq(i).attr("src","image/hongxin.png");
                                }
                            }
                        });
                    } else {
                        // //.log(data.message);
                    }
                });
        };

        //调用品牌圈轮播图
        //PinPaiBanner();
            // var params = {};
            // params.method = "article.get.pinpai.banner";
            // $http.get(baison.get_url('api/', params))
            //     .success(function (data) {
            //         if (data.status == 1) {
            //             $scope.banner = data.data;
            //             //等遍历完成再执行
            //             $scope.repeatFinish = function(){
            //                 $scope.swipers = $swipers.swp('.swiper-container',false,5000,1,1,'.swiper-pagination',null,null,0,false,function(){
            //                     return;
            //                 });
            //             };
            //         } else {
            //             // //.log(data.message);
            //         }
            //     });
                //消息中心
        //MessageCenter();
                // $(function(){
                //   var params = {};
                //   params.method = "article.get.my.comment.count";
                //   $http.get(baison.get_url('api/', params))
                //       .success(function (data) {
                //           if (data.status == 1) {
                //             $scope.lengdata = data.data.count;
                //             if($scope.lengdata == 0) $scope.hdbol = true; else $scope.hdbol = false;
                //           } else {
                //             $scope.hdbol = true;
                //               // //.log(data.message);
                //           }
                //       });
                // });
        //调取分类接口
        //ArticleCategory();
        //     $(function(){
        //         var params = {};
        //         params.method = "article.get.category";
        //         $http.get(baison.get_url('api/', params))
        //             .success(function (data) {
        //                 if (data.status == 1) {
        //                     $scope.data = data.data;
        //                     $scope.run1 = function($event){
        //                         if($event.target.nodeName == 'IMG' || $event.target.nodeName == 'DIV'){
        //                             var chuanId = $event.target.parentNode;
        //                             var chuanId1 = chuanId.getAttribute('id');
        //                         }else if($event.target.nodeName == 'P'){
        //                             var chuanId = $event.target.parentNode.parentNode;
        //                             var chuanId1 = chuanId.getAttribute('id');
        //                         }
        //                         if(chuanId1 == 22){
        //                             localStorage.setItem('zhuBaoDaPei',angular.toJson({data:'22'}));
        //                             $state.go('zhuBaoDaPeiList');
        //                         }else if(chuanId1 == 23){
        //                             //localStorage.setItem('sheJiShi',angular.toJson({data:'23'}));
        //                             $state.go('sheJiShiMoKuai');
        //                         }else if(chuanId1 == 24){
        //                             localStorage.setItem('zhuBaoXueTang',angular.toJson({data:'24'}));
        //                             $state.go('zhuBaoXueTangList');
        //                         }
        //                     };
        //                 } else {
        //                     // //.log(data.message);
        //                 }
        //             });
        //     });

        var Reload = function () {
            PinPaiBanner();
            alert('1');
            MessageCenter();
            alert('2');
            ArticleCategory();
            alert('3');
            ArticleSelect();
            alert('4');
        };
        Reload();
        alert('5');
        //调取热门文章的接口
        $(function(){
            alert(7);
            var params = {};
            params.method = "article.get.select";
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    alert('6');
                    if (data.status == 1) {
                        $scope.data1 = data.data;

                        $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
                          for(var i = 0;i<data.data.length;i++){
                            if($scope.data1[i].is_zan == 0){
                              $(".ppj_like_box_flxe-xin").eq(i).attr("src","image/heixin.png");
                            }else{
                              $(".ppj_like_box_flxe-xin").eq(i).attr("src","image/hongxin.png");
                            }
                          }
                        });
                        //$scope.$apply();
                    } else {
                        // //.log(data.message);
                    }
                    $(function(){
                        $('.dropload_content').dropload({
                            scrollArea : window,
                            domUp : {
                                domClass   : 'dropload-up',
                                domRefresh : '<div class="dropload-refresh"><img src="image/loading.gif" alt=""></div>',
                                domUpdate  : '<div class="dropload-update"><img src="image/loading.gif" alt=""></div>',
                                domLoad    : '<div class="dropload-load"><img src="image/loading.gif" alt=""></div>'
                            },
                            loadUpFn : function(me){
                                Reload();
                                setTimeout(function(){
                                    me.resetload();
                                    // 重置页数，重新获取loadDownFn的数据
                                    //  page = 0;
                                    // 解锁loadDownFn里锁定的情况
                                    me.unlock();
                                    me.noData(false);
                                    $scope.$apply();
                                },1000)

                            },
                            threshold : 50
                        });
                    });
                })
            .error(function(data){
                alert(data);
            });
        });
    }])

    //消息中心控制器
    .controller('messageCtrl',['$scope','$http','$state', function($scope,$http,$state) {

    }])
    //消息中心-留言点赞控制器
    .controller('xiaoXiZhongXinCtrl',['$rootScope','$scope','$http','$state', function($rootScope,$scope,$http,$state) {
      $(function(){
        var params = {};
        $scope.bolarr=[];
        $scope.bol = false;
        params.method = "article.get.my.comment";
        var p_params = {
            type:1
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (data.status == 1) {
                  $scope.data = data.data;
                  $scope.bolarr = [];
                  if(data.data.length == 0){
                    $scope.bol = false;
                  }else{
                    $scope.bol = true;
                  }
                  for(var i = 0;i<data.data.length;i++){
                    if(data.data[i].news_type == 0){
                      $scope.bolarr.push(false);
                    }else{
                      $scope.bolarr.push(true);
                    }
                  }
                } else {
                    // //.log(data.message);
                }
            });
      });
      /*****************************************************************************/
      var fasongbol = false;
      var iszan;
      var guodu = [];
      $scope.plbol = [];
      $scope.hfbol = [];
      $scope.tjbol = [];
      $scope.czbol = false;

        $scope.dianzanhf = function(comment_id,detail_id,k,index){
            var mudidiv = $(this).parents(".syly-win-main-liuyan-caozuo-zan").find(".zanhfs");
            var params = {};
            params.method = "article.set.comment.zan";
            var p_params = {
                comment_id:comment_id,
                detail_id:detail_id
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    if (data.status == 1) {
                        $scope.data = data.data;
                        mudidiv.html(Number(mudidiv.html())+1);
                        if(index == -1){
                            $scope.comment[k].zan = Number($scope.comment[k].zan)+1
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].is_zan = 1;
                        }else{
                            $scope.comment[k].detail[index].zan = Number($scope.comment[k].detail[index].zan)+1
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].detail[index].is_zan = 1;
                        }
                    }
                });
        }


        $scope.hfuserid = "";
        $scope.pingLun = {
            comment:function($event,type){
                $scope.commid = $scope.parcommid = '';
                $('#zbdp-comment').focus();
                $('#zbdp-comment').attr("placeholder","");
                if('comment' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main").index();
                    $scope.hfuserid = $scope.data[$scope.commid].nickname;
                }else if('reply' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main-huifu").index()-1;
                    $scope.parcommid = $($event.target).parents(".syly-win-main").index()-1;
                    $scope.hfuserid = $scope.data[$scope.parcommid].detail[$scope.commid].nickname;
                }
                $('#zbdp-comment').attr("placeholder","回复"+$scope.hfuserid);
                // if(/[^\x00-\xff]/ig.test($scope.hfuserid)){
                //   if($scope.hfuserid.match(/[^\x00-\xff]/ig).length>3){
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+2)*0.728+"rem");
                //   }else{
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+3)*0.718+"rem");
                //   }
                //   console.log($scope.hfuserid.match(/[^\x00-\xff]/ig).length);
                //   console.log($('#zbdp-comment').css("text-indent"));
                // }else{
                //   $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+1)*0.528+"rem");
                // }

                if($('.zbdp-footer-huifu-x').hasClass("disnone")){
                    //   $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                    $('.zbdp-footer-huifu-x').toggleClass("disnone");
                }

            },
            cancel:function(){
                $('#zbdp-comment').attr("placeholder","与姐妹们讨论下吧....");
                $('.zbdp-footer-input').val("");
                // $('#zbdp-comment').css("text-indent","0.768rem");
                $scope.hfuserid = "";
                // $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                $('.zbdp-footer-huifu-x').toggleClass("disnone");
            },
            pinglunsend:function(e){
                var keycode = window.event?e.keyCode:e.which;
                if(keycode == 13){
                    if($scope.hfuserid == ""){
                        var params = {};
                        params.method = "article.set.my.comment";
                        var p_params = {
                            // vip_code:$scope.comment[commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            article_id:wenzhangId
                        };
                    }else if(fasongbol){
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;
                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.comment[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.comment[$scope.parcommid].detail[$scope.commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            detail_id:$scope.comment[$scope.parcommid].detail[$scope.commid].detail_id
                        };
                    }else {
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;

                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.data[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.data[$scope.parcommid].vip_code,
                            remark:$('.zbdp-footer-input').val()
                        };
                    }

                    params.params = JSON.stringify(p_params);
                    $http.get(baison.get_url('api/', params))
                        .success(function (data) {
                            if (data.status == 1) {
                                $('.zbdp-footer-input').val("");
                                var params = {};
                                params.method = "article.get.my.comment";
                                var p_params = {
                                    type:1
                                };
                                params.params = JSON.stringify(p_params);
                                $http.get(baison.get_url('api/', params))
                                    .success(function (data) {
                                        if (data.status == 1) {
                                            $scope.data = data.data;
                                            $scope.bolarr = [];
                                            if(data.data.length == 0){
                                                $scope.bol = false;
                                            }else{
                                                $scope.bol = true;
                                            }
                                            for(var i = 0;i<data.data.length;i++){
                                                if(data.data[i].news_type == 0){
                                                    $scope.bolarr.push(false);
                                                }else{
                                                    $scope.bolarr.push(true);
                                                }
                                            }
                                        } else {
                                            // console.log(data.message);
                                        }
                                    });

                            } else if(data.status == -2){
                                alert(data.message);
                                $rootScope.notLoginMark();
                            }else{
                                alert(data.message);
                            }
                        });
                }
            }
        }
        //留言输入框显示
        $('.zbdp-footer-huifu').on('focus',function () {
            var _this = this;
            setTimeout(function () {
                _this.scrollIntoViewIfNeeded();
            },200)
        })
    }])
    //所有留言控制器
    .controller('suoYouLiuYanCtrl',['$rootScope','$scope','$http','$state', function($rootScope,$scope,$http,$state) {
        var wenzhangId = angular.fromJson(localStorage.getItem('wenzhangId')).data;
        var parcommid ="";
        var fasongbol = false;
        var iszan;
        $scope.hfbol = [];
        $scope.btnxianshibol = false;
        $scope.czbol = [];
        $scope.shoucang = function($event){
        if($event.target.nodeName == "IMG"){
          var targ = $event.target;
          var mudidiv = $($event.target).parents(".zbdp-footer-xihuan").find(".zbdp-footer-xihuan-wen");
        }
        var params = {};
        params.method = "article.set.article.zan";
        var p_params = {
            article_id:wenzhangId
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (data.status == 1) {
                  if(iszan == 0){
                    $($event.target).attr("src","image/hongxin.png");
                    iszan = 1;
                  }else{
                    $($event.target).attr("src","image/xin.png");
                    iszan = 0;
                  }
                    mudidiv.html(data.num);
                } else {
                    // //.log(data.message);
                }
            });

      };
        $scope.dianzanhf = function(comment_id,detail_id,k,index){
            var mudidiv = $(this).parents(".syly-win-main-liuyan-caozuo-zan").find(".zanhfs");
            var params = {};
            params.method = "article.set.comment.zan";
            var p_params = {
                comment_id:comment_id,
                detail_id:detail_id
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    if (data.status == 1) {
                        $scope.data = data.data;
                        mudidiv.html(Number(mudidiv.html())+1);
                        if(index == -1){
                            $scope.comment[k].zan = Number($scope.comment[k].zan)+1
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].is_zan = 1;
                        }else{
                            $scope.comment[k].detail[index].zan = Number($scope.comment[k].detail[index].zan)+1;
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].detail[index].is_zan = 1;
                        }
                    }
                });
        };
      fasongbol = false;
        var params = {};
        params.method = "article.get.sn";
        var p_params = {
            id:wenzhangId,
            limit:0
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (data.status == 1) {
                    //.log(data.data);
                    $scope.data = data.data;
                    if(data.data.recommend){
                      iszan = data.data.is_zan;
                      if(data.data.is_zan == 0){
                        $(".zbdp-footer-xihuan-img img").attr("src","image/xin.png");
                      }else{
                        $(".zbdp-footer-xihuan-img img").attr("src","image/hongxin.png");
                      }
                    }
                    var content = data.data.content;
                    var article_img = data.data.article_img;
                    $scope.comment = data.data.comment.content;
                    $scope.comment_count = data.data.comment.count;
                    if($scope.comment != undefined){

                        if(data.data.comment.count>=2){
                            $scope.btnxianshibol=true;
                        }

                        for(var i = 0;i<data.data.count;i++){
                            if(data.data.comment.content[i].detail !=undefined){
                                $scope.hfbol[i] = false;
                                $scope.czbol[i] = false;
                                if(data.data.comment.content[i].detail.length>0){
                                    $scope.hfbol[i]=true;
                                    if(data.data.comment.content[i].total >=2){
                                        $scope.czbol[i] = true;
                                    }else{
                                        $scope.czbol[i] = false;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    // //.log(data.message);
                }
            });

        $scope.hfuserid = "";
        $scope.pingLun = {
            comment:function($event,type){
                $scope.commid = $scope.parcommid = '';
                $('#zbdp-comment').focus();
                $('#zbdp-comment').attr("placeholder","");
                if('comment' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main").index();
                    $scope.hfuserid = $scope.comment[$scope.commid].name;
                    fasongbol = false;
                }else if('reply' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main-huifu").index()-1;
                    $scope.parcommid = $($event.target).parents(".syly-win-main").index();
                    $scope.hfuserid = $scope.comment[$scope.parcommid].detail[$scope.commid].nickname;
                    fasongbol = true;
                }

                $('#zbdp-comment').attr("placeholder","回复"+$scope.hfuserid);
                // if(/[^\x00-\xff]/ig.test($scope.hfuserid)){
                //   if($scope.hfuserid.match(/[^\x00-\xff]/ig).length>3){
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+2)*0.728+"rem");
                //   }else{
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+3)*0.718+"rem");
                //   }
                //   console.log($scope.hfuserid.match(/[^\x00-\xff]/ig).length);
                //   console.log($('#zbdp-comment').css("text-indent"));
                // }else{
                //   $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+1)*0.528+"rem");
                // }

                if($('.zbdp-footer-huifu-x').hasClass("disnone")){
                    //   $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                    $('.zbdp-footer-huifu-x').toggleClass("disnone");
                }

            },
            cancel:function(){
                $('#zbdp-comment').attr("placeholder","与姐妹们讨论下吧....");
                $('.zbdp-footer-input').val("");
                // $('#zbdp-comment').css("text-indent","0.768rem");
                $scope.hfuserid = "";
                fasongbol = false;
                // $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                $('.zbdp-footer-huifu-x').toggleClass("disnone");
            },
            pinglunsend:function(e){
                var keycode = window.event?e.keyCode:e.which;
                if(keycode == 13){
                    if($scope.hfuserid == ""){
                        var params = {};
                        params.method = "article.set.my.comment";
                        var p_params = {
                            // vip_code:$scope.comment[commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            article_id:wenzhangId
                        };
                    }else if(fasongbol){
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;
                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.comment[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.comment[$scope.parcommid].detail[$scope.commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            detail_id:$scope.comment[$scope.parcommid].detail[$scope.commid].detail_id
                        };
                    }else {
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;

                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.comment[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.comment[$scope.parcommid].vip_code,
                            remark:$('.zbdp-footer-input').val()
                        };
                    }

                    params.params = JSON.stringify(p_params);
                    $http.get(baison.get_url('api/', params))
                        .success(function (data) {
                            if (data.status == 1) {
                                $('.zbdp-footer-input').val("");
                                var params = {};
                                params.method = "article.get.sn";
                                var p_params = {
                                    id:wenzhangId,
                                    limit:0,
                                };
                                params.params = JSON.stringify(p_params);
                                $http.get(baison.get_url('api/', params))
                                    .success(function (data) {
                                        if (data.status == 1) {
                                            $scope.comment = data.data.comment.content;
                                        } else {
                                            // console.log(data.message);
                                        }
                                    });
                            } else if(data.status == -2){
                                alert(data.message);
                                $rootScope.notLoginMark();
                            }else{
                                alert(data.message);
                            }
                        });
                }
            }
        };
        //留言输入框显示
        $('.zbdp-footer-huifu').on('focus',function () {
            var _this = this;
            setTimeout(function () {
                _this.scrollIntoViewIfNeeded();
            },200)
        })
    }])

    //珠宝搭配控制器
    .controller('zhuBaoDaPeiCtrl',['$scope','$share','$http','$rootScope','$state','$stateParams', function($scope,$share,$http,$rootScope,$state,$stateParams) {
        //解决ios fixed 兼容性问题
       /* $scope.input_focus=function(e){
            var input_event=e.target;
            setTimeout(function(){
                $(window).scrollTop(document.body.scrollHeight+10000);
            },500);
            $('.zbdp-footer').css({
                "position":"relative"
            });
        };
        $scope.input_blur=function(e) {
            $(".zbdp-footer").css({
                "position": "fixed",
                "bottom": 0,
                "top": 'auto'
            });
            window.onscroll = null;
            $scope.input_toggle = 0;
        };*/
        ////分享显示
        //$scope.fenXiang = false;
        //$scope.fenXiangF = function(){
        //    $scope.fenXiang = !$scope.fenXiang
        //};
        var fasongbol = false;
        var iszan;
        var article_id = $stateParams.id;
        localStorage.setItem('wenzhangId',angular.toJson({data:article_id}));
        $scope.gengduopinglun=function(){
          $state.go("suoYouLiuYan");
        };


        $scope.hfbol = [];
        $scope.btnbol = false;
        $scope.btnxianshibol = false;
        $scope.czbol = [];
        $scope.shoucang = function($event){
            // if($event.target.nodeName == "IMG"){
                // var mudidiv = $($event.target).parents(".zbdp-footer-right").find(".zbdp-footer-xihuan-wen");
                var params = {};
                params.method = "article.set.article.zan";
                var p_params = {
                    article_id:article_id
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function (data) {
                        if (data.status == 1) {
                          // console.log(iszan);
                            if(iszan == 0){
                                $($event.target).parents('.zbdp-footer-right').find('img').attr("src","image/hongxin.png");
                                iszan = 1;
                            }else{
                                $($event.target).parents('.zbdp-footer-right').find('img').attr("src","image/xin.png");
                                iszan = 0;
                                // console.log("image/hongxin.png");
                            }
                            $scope.data.praise_num = data.data.num;
                            // mudidiv.html(data.num);

                        } else {
                            alert(data.message);
                            if(data.status==-1){
                                $rootScope.notLoginMark();
                            }
                        }
                });
            // }
        };
        $scope.dianzanhf = function(comment_id,detail_id,k,index){
            var mudidiv = $(this).parents(".syly-win-main-liuyan-caozuo-zan").find(".zanhfs");
            var params = {};
            params.method = "article.set.comment.zan";
            var p_params = {
                comment_id:comment_id,
                detail_id:detail_id
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    if (data.status == 1) {
                        // $scope.data = data.data;
                        // $scope.data.praise_num++;
                        mudidiv.html(Number(mudidiv.html())+1);
                        if(index == -1){
                            $scope.comment[k].zan = Number($scope.comment[k].zan)+1
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].is_zan = 1;
                        }else{
                            $scope.comment[k].detail[index].zan = Number($scope.comment[k].detail[index].zan)+1;
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].detail[index].is_zan = 1;
                        }
                    }
                });
        };
        var params = {};
        params.method = "article.get.sn";
        var p_params = {
            id:article_id,
            limit:3
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (data.status == 1) {
                    $scope.data = data.data;
                    //分享
                    var shareText = $scope.data.title;//分享的标题
                    var sharePath = location.href;
                    var hrefStart = sharePath.indexOf('#');
                    hrefStart = sharePath.slice(hrefStart);
                    var sharePathLast = baison.site + 'theme/web5/' + hrefStart;//获取分享的链接
                    $scope.shareF = function() {
                        $share.share({
                            text: shareText,
                            type: 'url',
                            path: sharePathLast
                        });
                    };

                    if(data.data.recommend){
                      iszan = data.data.is_zan;
                      if(data.data.is_zan == 0){
                        $(".zbdp-footer-xihuan-img img").attr("src","image/xin.png");
                      }else{
                        $(".zbdp-footer-xihuan-img img").attr("src","image/hongxin.png");
                      }
                        $scope.recommend = data.data.recommend;//推荐文章
                        $scope.toUrl = function(cat_id,article_id){
                            if($scope.recommend.cat_id == '22'){
                                $state.go('zhuBaoDaPei',{
                                    id:article_id
                                })
                            }else if($scope.recommend.cat_id == '24'){
                                $state.go('zhuBaoXueTang',{
                                    id:article_id
                                })
                            }
                        };
                    }
                    //$scope.recommend = data.data.recommend;//推荐文章
                    ////.log($scope.recommend.cat_id);
                    ////.log($scope.recommend.article_id);
                    //$scope.toUrl = function(cat_id,article_id){
                    //    if($scope.recommend.cat_id == '22'){
                    //        //localStorage.setItem('zhuBaoXueTangId',angular.toJson({data:$scope.recommend.article_id}));
                    //        $state.go('zhuBaoXueTang',{
                    //            id:article_id
                    //        })
                    //    }else if($scope.recommend.cat_id == '24'){
                    //        //localStorage.setItem('zhuBaoDaPeiId',angular.toJson({data:$scope.recommend.article_id}));
                    //        $state.go('zhuBaoDaPei',{
                    //            id:article_id
                    //        },{reload:'zhuBaoDaPei'})
                    //    }
                    //};
                    var content = data.data.content;
                    var article_img = data.data.article_img;

                    if(data.data.comment){
                        $scope.comment = data.data.comment.content;
                    }

                    if (typeof(data.data.comment) != "undefined") {
                        //$scope.comment = data.data.comment.content;
                        if($scope.comment != undefined){
                            if(data.data.comment.count>0){
                                $scope.btnbol=true;
                            }
                            if(data.data.comment.count>=1){
                                $scope.btnxianshibol=true;
                            }

                            for(var i = 0;i<data.data.comment.count;i++){
                                if(data.data.comment.content[i].detail !=undefined){
                                    $scope.hfbol[i] = false;
                                    $scope.czbol[i] = false;
                                    if(data.data.comment.content[i].detail.length>0){
                                        $scope.hfbol[i]=true;
                                        if(data.data.comment.content[i].total >=2){
                                            $scope.czbol[i] = true;
                                        }else{
                                            $scope.czbol[i] = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $('#zhuBaoDaPei_content').html(content);
                    $('#zbdp-header').css({background:'url('+article_img+')',backgroundSize:'100% 100%'});
                } else {
                    // //.log(data.message);
                }
                // 珠宝搭配头部滚动条
                $("#cpxq_rgba span").hide();
                $(".zbdp-wrap").scroll(function () {
                    var winPos1 = $(".zbdp-wrap").scrollTop() * 0.0066;
                    if (winPos1 < 1.5) {
                        $("#cpxq_rgba span").show();
                        $("#cpxq_rgba").css("background-color", "rgba" + "(" + 255 + "," + 255 + "," + 255 + "," + winPos1 + ")");
                        $("#cpxq_rgba span").css("color", "rgba" + "(" + 50 + "," + 50 + "," + 50 + "," + winPos1 + ")");
                    }
                });
            });

        $scope.hfuserid = "";
        $scope.pingLun = {
            comment:function($event,type){
                $scope.commid = $scope.parcommid = '';
                $('#zbdp-comment').focus();
                $('#zbdp-comment').attr("placeholder","");
                if('comment' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main").index()-1;
                    $scope.hfuserid = $scope.comment[$scope.commid].name;
                    fasongbol = false;
                }else if('reply' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main-huifu").index()-1;
                    $scope.parcommid = $($event.target).parents(".syly-win-main").index()-1;
                    $scope.hfuserid = $scope.comment[$scope.parcommid].detail[$scope.commid].nickname;
                    fasongbol = true;
                }

                $('#zbdp-comment').attr("placeholder","回复"+$scope.hfuserid);
                // if(/[^\x00-\xff]/ig.test($scope.hfuserid)){
                //   if($scope.hfuserid.match(/[^\x00-\xff]/ig).length>3){
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+2)*0.728+"rem");
                //   }else{
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+3)*0.718+"rem");
                //   }
                //   console.log($scope.hfuserid.match(/[^\x00-\xff]/ig).length);
                //   console.log($('#zbdp-comment').css("text-indent"));
                // }else{
                //   $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+1)*0.528+"rem");
                // }

                if($('.zbdp-footer-huifu-x').hasClass("disnone")){
                    //   $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                    $('.zbdp-footer-huifu-x').toggleClass("disnone");
                }

            },
            cancel:function(){
                $('#zbdp-comment').attr("placeholder","与姐妹们讨论下吧....");
                $('.zbdp-footer-input').val("");
                // $('#zbdp-comment').css("text-indent","0.768rem");
                $scope.hfuserid = "";
                // $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                $('.zbdp-footer-huifu-x').toggleClass("disnone");
                fasongbol = false;
            },
            pinglunsend:function(e){
                var keycode = window.event?e.keyCode:e.which;
                if(keycode == 13){
                    if($scope.hfuserid == ""){
                        var params = {};
                        params.method = "article.set.my.comment";
                        var p_params = {
                            // vip_code:$scope.comment[commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            article_id:article_id
                        };
                    }else if(fasongbol){
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;
                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.comment[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.comment[$scope.parcommid].detail[$scope.commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            detail_id:$scope.comment[$scope.parcommid].detail[$scope.commid].detail_id
                        };
                    }else {
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;

                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.comment[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.comment[$scope.parcommid].vip_code,
                            remark:$('.zbdp-footer-input').val()
                        };
                    }

                    params.params = JSON.stringify(p_params);
                    $http.get(baison.get_url('api/', params))
                        .success(function (data) {
                            if (data.status == 1) {
                                $('.zbdp-footer-input').val("");
                                var params = {};
                                params.method = "article.get.sn";
                                var p_params = {
                                    id:article_id,
                                    limit:3,
                                };
                                params.params = JSON.stringify(p_params);
                                $http.get(baison.get_url('api/', params))
                                    .success(function (data) {
                                        if (data.status == 1) {
                                            $scope.comment = data.data.comment.content;
                                        } else {
                                            // console.log(data.message);
                                        }
                                    });
                            } else if(data.status == -2){
                                alert(data.message);
                                $rootScope.notLoginMark();
                            }else{
                                alert(data.message);
                            }
                        });
                }
            }
        };
        //留言输入框显示
        $('.zbdp-footer-huifu').on('focus',function () {
            var _this = this;
            setTimeout(function () {
                _this.scrollIntoViewIfNeeded();
            },200)
        })
    }])

    //珠宝学堂控制器
    .controller('zhuBaoXueTangCtrl',['$scope','$share','$http','$state','$rootScope','$stateParams', function($scope,$share,$http,$state,$rootScope,$stateParams) {
        ////分享显示
        //$scope.fenXiang = false;
        //$scope.fenXiangF = function(){
        //    $scope.fenXiang = !$scope.fenXiang
        //};
        var fasongbol = false;
        var iszan;
        var article_id = $stateParams.id;
        localStorage.setItem('wenzhangId',angular.toJson({data:article_id}));
        $scope.gengduopinglun=function(){
          $state.go("suoYouLiuYan");
        };
        $scope.hfbol = [];
        $scope.btnxianshibol = false;
        $scope.czbol = [];
        $scope.shoucang = function($event){
            // if($event.target.nodeName == "IMG"){
                // var mudidiv = $($event.target).parents(".zbdp-footer-right").find(".zbdp-footer-xihuan-wen");
                var params = {};
                params.method = "article.set.article.zan";
                var p_params = {
                    article_id:article_id
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function (data) {
                        if (data.status == 1) {
                          // console.log(iszan);
                            if(iszan == 0){
                                $($event.target).parents('.zbdp-footer-right').find('img').attr("src","image/hongxin.png");
                                iszan = 1;
                            }else{
                                $($event.target).parents('.zbdp-footer-right').find('img').attr("src","image/xin.png");
                                iszan = 0;
                                // console.log("image/hongxin.png");
                            }
                            $scope.data.praise_num = data.data.num;
                            // mudidiv.html(data.num);

                        } else {
                            alert(data.message);
                            if(data.status==-1){
                                $rootScope.notLoginMark();
                            }
                        }
                });
            // }
        };
        $scope.dianzanhf = function(comment_id,detail_id,k,index){
            var mudidiv = $(this).parents(".syly-win-main-liuyan-caozuo-zan").find(".zanhfs");
            var params = {};
            params.method = "article.set.comment.zan";
            var p_params = {
                comment_id:comment_id,
                detail_id:detail_id
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    if (data.status == 1) {
                        // $scope.data = data.data;
                        mudidiv.html(Number(mudidiv.html())+1);
                        if(index == -1){
                            $scope.comment[k].zan = Number($scope.comment[k].zan)+1
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].is_zan = 1;
                        }else{
                            $scope.comment[k].detail[index].zan = Number($scope.comment[k].detail[index].zan)+1;
                            //$($event.target).attr("src","image/redzan.jpg");
                            $scope.comment[k].detail[index].is_zan = 1;
                        }
                    }
                });
        };
        var params = {};
        params.method = "article.get.sn";
        var p_params = {
            id:article_id,
            limit:3
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (data.status == 1) {
                    $scope.data = data.data;
                    //分享
                    var shareText = $scope.data.title;
                    var sharePath = location.href;
                    var hrefStart = sharePath.indexOf('#');
                    hrefStart = sharePath.slice(hrefStart);
                    var sharePathLast = baison.site + 'theme/web5/' + hrefStart;
                    $scope.shareF = function() {
                        $share.share({
                            text: shareText,
                            type: 'url',
                            path: sharePathLast
                        });
                    };
                    var content = data.data.content;
                    var article_img = data.data.article_img;
                    iszan = data.data.is_zan;
                    if(data.data.is_zan == 0){
                      $(".zbdp-footer-xihuan-img img").attr("src","image/xin.png");
                    }else{
                        $(".zbdp-footer-xihuan-img img").attr("src","image/hongxin.png");
                    }
                    if(data.data.recommend){
                        $scope.recommend = data.data.recommend;//推荐文章
                        $scope.toUrl = function(cat_id,article_id){
                            if($scope.recommend.cat_id == '22'){
                                $state.go('zhuBaoDaPei',{
                                    id:article_id
                                })
                            }else if($scope.recommend.cat_id == '24'){
                                $state.go('zhuBaoXueTang',{
                                    id:article_id
                                })
                            }
                        };
                    }
                    if(data.data.comment){
                        $scope.comment = data.data.comment.content;
                    }
                    var content = data.data.content;
                    var article_img = data.data.article_img;

                    $scope.btnbol=false;
                    $scope.btnxianshibol=false;
                    if($scope.comment != undefined){

                        if(data.data.comment.count>0){
                            $scope.btnbol=true;
                        }
                        if(data.data.comment.count>=1){
                            $scope.btnxianshibol=true;
                        }

                        for(var i = 0;i<data.data.comment.count;i++){
                            if(data.data.comment.content[i].detail !=undefined){
                                $scope.hfbol[i] = false;
                                $scope.czbol[i] = false;
                                if(data.data.comment.content[i].detail.length>0){
                                    $scope.hfbol[i]=true;
                                    if(data.data.comment.content[i].total >=2){
                                        $scope.czbol[i] = true;
                                    }else{
                                        $scope.czbol[i] = false;
                                    }
                                }
                            }
                        }
                    }
                    $('#zbxt-body-fwen').html(content);
                    $('#zbxt-header').css({background:'url('+article_img+')',backgroundSize:'100% 100%'});
                } else {
                    // //.log(data.message);
                }
                // 珠宝学堂头部滚动条
                $("#cpxq_rgba span").hide();
                $(".zbdp-wrap").scroll(function () {
                    var winPos1 = $(".zbdp-wrap").scrollTop() * 0.0066;
                    if (winPos1 < 1.5) {
                        $("#cpxq_rgba span").show();
                        $("#cpxq_rgba").css("background-color", "rgba" + "(" + 255 + "," + 255 + "," + 255 + "," + winPos1 + ")");
                        $("#cpxq_rgba span").css("color", "rgba" + "(" + 50 + "," + 50 + "," + 50 + "," + winPos1 + ")");
                    }
                });
            });

        $scope.hfuserid = "";
        $scope.pingLun = {
            comment:function($event,type){
                $scope.commid = $scope.parcommid = '';
                $('#zbdp-comment').focus();
                $('#zbdp-comment').attr("placeholder","");
                if('comment' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main").index()-1;
                    $scope.hfuserid = $scope.comment[$scope.commid].name;
                    fasongbol = false;
                }else if('reply' == type){
                    $scope.commid = $($event.target).parents(".syly-win-main-huifu").index()-1;
                    $scope.parcommid = $($event.target).parents(".syly-win-main").index()-1;
                    $scope.hfuserid = $scope.comment[$scope.parcommid].detail[$scope.commid].nickname;
                    fasongbol = true;
                }

                $('#zbdp-comment').attr("placeholder","回复"+$scope.hfuserid);
                // if(/[^\x00-\xff]/ig.test($scope.hfuserid)){
                //   if($scope.hfuserid.match(/[^\x00-\xff]/ig).length>3){
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+2)*0.728+"rem");
                //   }else{
                //     $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+3)*0.718+"rem");
                //   }
                //   console.log($scope.hfuserid.match(/[^\x00-\xff]/ig).length);
                //   console.log($('#zbdp-comment').css("text-indent"));
                // }else{
                //   $('#zbdp-comment').css("text-indent",($scope.hfuserid.length+1)*0.528+"rem");
                // }

                if($('.zbdp-footer-huifu-x').hasClass("disnone")){
                    //   $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                    $('.zbdp-footer-huifu-x').toggleClass("disnone");
                }

            },
            cancel:function(){
                $('#zbdp-comment').attr("placeholder","与姐妹们讨论下吧....");
                $('.zbdp-footer-input').val("");
                // $('#zbdp-comment').css("text-indent","0.768rem");
                $scope.hfuserid = "";
                fasongbol = false;
                // $('.zbdp-footer-huifu-ren').toggleClass("disnone");
                $('.zbdp-footer-huifu-x').toggleClass("disnone");
            },
            pinglunsend:function(e){
                var keycode = window.event?e.keyCode:e.which;
                if(keycode == 13){
                    if($scope.hfuserid == ""){
                        var params = {};
                        params.method = "article.set.my.comment";
                        var p_params = {
                            // vip_code:$scope.comment[commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            article_id:article_id
                        };
                    }else if(fasongbol){
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;
                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.comment[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.comment[$scope.parcommid].detail[$scope.commid].vip_code,
                            remark:$('.zbdp-footer-input').val(),
                            detail_id:$scope.comment[$scope.parcommid].detail[$scope.commid].detail_id
                        };
                    }else {
                        var params = {};
                        if($scope.parcommid == '') $scope.parcommid = $scope.commid;

                        params.method = "article.set.my.comment";
                        var p_params = {
                            comment_id:$scope.comment[$scope.parcommid].comment_id,
                            reply_vip_code:$scope.comment[$scope.parcommid].vip_code,
                            remark:$('.zbdp-footer-input').val()
                        };
                    }

                    params.params = JSON.stringify(p_params);
                    $http.get(baison.get_url('api/', params))
                        .success(function (data) {
                            if (data.status == 1) {
                                $('.zbdp-footer-input').val("");
                                var params = {};
                                params.method = "article.get.sn";
                                var p_params = {
                                    id:article_id,
                                    limit:3,
                                };
                                params.params = JSON.stringify(p_params);
                                $http.get(baison.get_url('api/', params))
                                    .success(function (data) {
                                        if (data.status == 1) {
                                            $scope.comment = data.data.comment.content;
                                        } else {
                                            // console.log(data.message);
                                        }
                                    });
                            } else if(data.status == -2){
                                alert(data.message);
                                $rootScope.notLoginMark();
                            }else{
                                alert(data.message);
                            }
                        });
                }
            }
        };
        //留言输入框显示
        $('.zbdp-footer-huifu').on('focus',function () {
            var _this = this;
            setTimeout(function () {
                _this.scrollIntoViewIfNeeded();
            },200)
        })
    }])
    //珠宝学堂列表
    .controller('zhuBaoXueTangListCtrl',['$scope','$http','$state', function($scope,$http,$state) {
        //控制跳转
        $scope.toUrl = function(aid){
            $state.go('zhuBaoXueTang',{
                id:aid
            })
        };
        var login_name = angular.fromJson(localStorage.getItem('zhuBaoXueTang'));
        var login_name1 = login_name.data;
        // //.log(login_name1);
        var params = {};
        params.method = "article.get.list";
        var p_params = {
            cid:login_name1
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (data.status == 1) {
                    $scope.data = data.data;
                    $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
                      for(var i = 0;i<data.data.length;i++){
                        if(data.data[i].is_zan == 0){
                          $(".ppj_section_box").eq(i).find(".ppj_like_box_flxe-xin").attr("src","image/heixin.png");
                        }else{
                          $(".ppj_section_box").eq(i).find(".ppj_like_box_flxe-xin").attr("src","image/hongxin.png");
                        }
                      }
                    });
                    //localStorage.removeItem('zhuBaoXueTang');
                } else {
                    // //.log(data.message);
                }
            });
        //留言输入框显示
        $('.zbdp-footer-huifu').on('focus',function () {
            var _this = this;
            setTimeout(function () {
                _this.scrollIntoViewIfNeeded();
            },200)
        })
    }])
    //珠宝搭配列表控制器
    .controller('zhuBaoDaPeiListCtrl',['$scope','$http','$state','$stateParams', function($scope,$http,$state,$stateParams) {
        //控制跳转
        $scope.toUrl = function(aid){
            $state.go('zhuBaoDaPei',{
                id:aid
            })
        };
        var login_name = angular.fromJson(localStorage.getItem('zhuBaoDaPei'));
        var login_name1 = login_name.data;
        var params = {};
        params.method = "article.get.list";
        var p_params = {
            cid:login_name1
        };
        params.params = JSON.stringify(p_params);
        $http.get(baison.get_url('api/', params))
            .success(function (data) {
                if (data.status == 1) {
                    $scope.data = data.data;
                    $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
                      for(var i = 0;i<data.data.length;i++){
                        if(data.data[i].is_zan == 0){
                          $(".ppj_section_box").eq(i).find(".ppj_like_box_flxe-xin").attr("src","image/heixin.png");
                        }else{
                          $(".ppj_section_box").eq(i).find(".ppj_like_box_flxe-xin").attr("src","image/hongxin.png");
                        }
                      }
                    });
                    //localStorage.removeItem('zhuBaoDaPei');
                } else {
                    // //.log(data.message);
                }
            });
    }])
    //设计师模块控制器
    .controller('sheJiShiMoKuaiCtrl',['$scope','$http','$state','$swipers', function($scope,$http,$state,$swipers) {


        //调用设计师列表

        $(function(){
            var params = {};
            params.method = "article.designer.get.list";
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    if (data.status == 1) {
                        $scope.sheJiShiMoKuai = data.data;
                        $(".blur").attr("src",$scope.sheJiShiMoKuai[0].b_pic);
                        $(".sjsmk_ince_box h4").html($scope.sheJiShiMoKuai[0].name);
                    } else {
                        // //.log(data.message);
                    }
                });
        });
        $scope.goUrl = function(url){
            $state.go('sheJiShiZhuanLan',{
                id:url
            })
        };
        $scope.repeatFinish = function(){
            $scope.swipers=$swipers.swp('.swiper-container',false,0,1,1,null,null,null,-2*document.body.clientWidth*0.0555555555555556,false,function(swiper){
                $(".blur").attr("src",$(".sjsmk_figure").eq(swiper.activeIndex).attr("src"));
                $(".sjsmk_ince_box h4").html($(".sjsmk_ret_brg p").eq(swiper.activeIndex).html());
            });
        }

    }])

    //设计师专栏控制器
    .controller('sheJiShiZhuanLanCtrl',['$scope','$http','$state','$stateParams', function($scope,$http,$state,$stateParams) {
        //调用设计师文章详情
        $(function(){
            var getId = $stateParams.id;
            var params = {};
            params.method = "article.designer.by.id";
            var p_params = {
                id:getId
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function (data) {
                    if (data.status == 1) {
                        $scope.data = data.data;
                        $scope.designer = $scope.data.designer;
                        $scope.b_pic = $scope.designer.b_pic;
                        $('#sjszl_header').css({background:'url('+$scope.designer.t_pic+')'});
                        //控制跳转
                        $scope.goUrl = function(cat_id,article_id){
                            if(cat_id == '22'){
                                $state.go('zhuBaoXueTang',{
                                    id:article_id
                                })
                            }else if(cat_id == '24'){
                                $state.go('zhuBaoDaPei',{
                                    id:article_id
                                })
                            }
                        };
                    } else {
                        //
                    }
                });
        })
    }])

//首页模块控制器   结束----------------------------------------------------------

//个人中心控制器模块    开始-----------------------------------------------------
// 订单处理控制器
.controller('dingDanChuLiCtrl',['$scope','$http','$state', function($scope,$http,$state) {

}])
// 卡券控制器
.controller('kaQuanCtrl',['$scope','$http','$state', function($scope,$http,$state) {
        var Userlogin = angular.fromJson(localStorage.getItem('loginName'));
        $scope.kqbol=true;
        if(Userlogin){
            $(function(){
              var params = {};
              params.method = "member.get.coupon";
              $http.get(baison.get_url('api/', params))
                 .success(function (data) {
                     if (data.data.length > 0 ) {
                       $scope.data = data.data;
                        //  //.log(data.data);
                     } else {
                       $scope.kqbol=false;
                        //  //.log(data.message);
                     }
                 });
            });
        }

}])
// 喜欢列表控制器
.controller('loveListCtrl',['$scope','$http','$state', function($scope,$http,$state) {

}])
// 门店指引控制器
.controller('mdzyCtrl',['$scope','$http','$state','$bMap', function($scope,$http,$state,$bMap) {
  $scope.$on('$viewContentLoaded', function(){

  });
$('.mdzy_map_text_box').hide();
var screenw = screen.width;
var screeny = (1.076+2.288)/18*750;
var screenh = screen.height-1.076/18*750;
var xianshibol = true;
$scope.change=function(){
  if(xianshibol){
    $bMap.bMaphidden();
    $(".mdzy_map_text_box").addClass("disnone");
    xianshibol = !xianshibol;
  }else{
    $bMap.bMapshow();
    $(".mdzy_map_text_box").removeClass("disnone");
    xianshibol = !xianshibol;
  }
};
  $scope.baidumap = function(){
    $bMap.bMap(screeny,screenw,screenh);
  };
    setTimeout(function(){
      $(".mdzy_title").click();
    },500);
  $scope.bMclose=function(){
    $bMap.bMapclose();
  };
  $scope.baidumapNP = function(){
    $bMap.bMapNP();
  };
  $scope.searchtext={
    text:""
  };
  $scope.cancel = function(){
    $scope.searchtext.text="";
  };
  $scope.disbol=true;
  var bMapbol=false;
  var bMaparr=[];
  $scope.searchmd = function(e){
    var keycode = window.event?e.keyCode:e.which;
    if(keycode == 13){
    $(".mdzy_dw_search").blur();
    var searchtext = $scope.searchtext.text;
    var params = {};
    params.method = "member.store";
    var p_params = {
        region_name:searchtext
    };
    params.params = JSON.stringify(p_params);
    $http.get(baison.get_url('api/', params))
       .success(function (data) {
           if (data.status == 1) {
             if(bMapbol){
               $bMap.bMapRemoveP(bMaparr);
             }
             $scope.addrdata = data.data.stores;
             $scope.addrsize = data.data.stores.length;
             $scope.disbol=false;
             bMapbol = true;
             for(var i = 0;i<$scope.addrsize;i++){
               if($scope.addrdata[i].longitude!=""&&$scope.addrdata[i].latitude!=""){
                 var lot = $scope.addrdata[i].longitude;
                 var lat = $scope.addrdata[i].latitude;
                 bMaparr[i] = i+1;
                 $bMap.bMapDPP(i+1,lot,lat,function(ret){
                   screenh = screen.height-1.076/18*750-4.547488/18*750;
                   $bMap.setRect(screeny,screenw,screenh);
                   $scope.mpid = ret.id;
                   $scope.mpname = data.data.stores[ret.id-1].stores_name;
                   $scope.mpaddr = data.data.stores[ret.id-1].stores_address;
                   $scope.mpphone = data.data.stores[ret.id-1].stores_tel;
                   $scope.$apply();
                 });
               }
             }
             if($scope.addrdata.length>0){
               var lengths = parseInt($scope.addrdata.length/2);
              //  //.log(lengths+"lengths");
               if(lengths>=2){
                 var bmclon = $scope.addrdata[lengths].longitude;
                 var bmclat = $scope.addrdata[lengths].latitude;
                 $bMap.bMapsetcent(bmclon,bmclat);
               }
               if(lengths<2&&lengths>=0){
                 var bmclon = $scope.addrdata[0].longitude;
                 var bmclat = $scope.addrdata[0].latitude;
                 $bMap.bMapsetcent(bmclon,bmclat);
               }
             }

           } else {
              alert('该地址下无门店信息')
           }
       });
     }
  }
}])
// 订单详情控制器
.controller('dingDanXiangQingCtrl',['$scope','$http','$state', '$stateParams','$openapp','$timeout', function($scope,$http,$state, $stateParams,$openapp,$timeout) {
  var dingdancode = $stateParams.id;
  var uname = angular.fromJson(localStorage.getItem('loginName'));
        if (uname) {
            //小能客服
            NTKF_PARAM = {
                siteid: "kf_9048", //企业ID，为固定值，必填
                settingid: "kf_9048_1500372366880", //接待组ID，为固定值，必填
                uid: uname.username, //用户ID，未登录可以为空，但不能给null，uid赋予的值显示到小能客户端上
                uname: uname.username, //用户名，未登录可以为空，但不能给null，uname赋予的值显示到小能客户端上
                isvip: "0", //是否为vip用户，0代表非会员，1代表会员，取值显示到小能客户端上
                userlevel: "1", //网站自定义会员级别，0-N，可根据选择判断，取值显示到小能客户端上
                erpparam: "abc" //erpparam为erp功能的扩展字段，可选，购买erp功能后用于erp功能集成
            };
        } else {
            //小能客服
            NTKF_PARAM = {
                siteid: "kf_9048", //企业ID，为固定值，必填
                settingid: "kf_9048_1500372366880", //接待组ID，为固定值，必填
                uid: '', //用户ID，未登录可以为空，但不能给null，uid赋予的值显示到小能客户端上
                uname: '游客', //用户名，未登录可以为空，但不能给null，uname赋予的值显示到小能客户端上
                isvip: "0", //是否为vip用户，0代表非会员，1代表会员，取值显示到小能客户端上
                userlevel: "1", //网站自定义会员级别，0-N，可根据选择判断，取值显示到小能客户端上
                erpparam: "abc" //erpparam为erp功能的扩展字段，可选，购买erp功能后用于erp功能集成
            };
        }
  var params = {};
  // params.method = "order.list.order";
  params.method = "order.trade.get";
  var p_params = {
      order_id: dingdancode,
  };
  params.params = JSON.stringify(p_params);
  $http.get(baison.get_url('api/', params))
     .success(function (data) {
         if (data.code == 1) {
          // for(var i = 0;i<data.data.order_list.length;i++){
          //   if(data.data.order_list[i].record_code==dingdancode){
          //     dingdanId = i;
          //   }
          // }
          // $scope.data = data.data.order_list[dingdanId];
             $scope.data = data.data;
             $scope.addrdata = {
                name: $scope.data.name,
                mobile: $scope.data.mobile,
                province_name: $scope.data.province,
                city_name: $scope.data.city,
                district: $scope.data.district,
                address: $scope.data.address
             };
             if($scope.data.status_name == "处理中"){
                 $scope.yfkdfhbol=true;
                 $scope.yifahuobol=false;
                 $scope.yidaohuobol=false;
                 $scope.wanchengbol=false;
                 $scope.yiquxiaobol=false;
                 $scope.weifukuanbol=false;
                 var record_code=$scope.data.record_code;
                 //提醒发货
                 $scope.remind=function(){
                     var params = {};
                     params.method = "order.send.remind";
                     var p_params = {
                         code:record_code
                     };
                     params.params = JSON.stringify(p_params);
                     $http.get(baison.get_url('api/', params)).success(function (data) {
                         alert(data.message)
                     })
                 };
             }else if($scope.data.status_name == "未付款"){
                 $scope.yfkdfhbol=false;
                 $scope.yifahuobol=false;
                 $scope.yidaohuobol=false;
                 $scope.wanchengbol=false;
                 $scope.yiquxiaobol=false;
                 $scope.weifukuanbol=true;
             }else if($scope.data.status_name == "已取消"){
                 $scope.weifukuanbol=false;
                 $scope.yfkdfhbol=false;
                 $scope.yifahuobol=false;
                 $scope.yidaohuobol=false;
                 $scope.wanchengbol=false;
                 $scope.yiquxiaobol=true;
             }else if($scope.data.status_name == "已发货"){
                 $scope.weifukuanbol=false;
                 $scope.yfkdfhbol=false;
                 $scope.yifahuobol=true;
                 $scope.yidaohuobol=false;
                 $scope.wanchengbol=false;
                 $scope.yiquxiaobol=false;
             }else if($scope.data.status_name == "已完成"){
                 $scope.weifukuanbol=false;
                 $scope.yfkdfhbol=false;
                 $scope.yifahuobol=false;
                 $scope.yidaohuobol=false;
                 $scope.wanchengbol=true;
                 $scope.yiquxiaobol=false;
             }
             $scope.wuliu = function(express_code,express_no,express_name){
                 localStorage.setItem('express',angular.toJson({
                     express_code:express_code,
                     express_no:express_no,
                     express_name:express_name
                 }));
                 $state.go("wuLiuXinXi");
             };
           $scope.quxiao=function($event){
             var tfbol = "";
             $(".gwc_zzc_queren").toggleClass("disnone");
             $scope.tfselect = function($event) {
                 if ($($event.target).attr("class") == "gwc_zzc_confirm") {
                     tfbol = true;
                 } else if ($($event.target).attr("class") != "gwc_zzc_confirm") {
                     tfbol = false;
                 }
                 $(".gwc_zzc_queren").toggleClass("disnone");
                 if (tfbol) {
            //  var quxiaoindex = $($event.target).parents(".wddd_section-box").index();
             var oids = $scope.data.record_code;

             var params = {};
             params.method = "order.cancel.order";
             params.oid=oids;
            //  params.params = JSON.stringify(p_params);
             $http.get(baison.get_url('api/', params))
                 .success(function (data) {
                  //  //.log(data);
                     if (data.status == 1) {
                       var params = {};
                        params.method = "order.trade.get";
                          var p_params = {
                              order_id: dingdancode
                          };
                          params.params = JSON.stringify(p_params);
                       $http.get(baison.get_url('api/', params))
                           .success(function (data) {
                            //  //.log(data);
                               if (data.status == 1) {
                                 $scope.data = data.data;
                                 if($scope.data.status_name == "处理中"){
                                   $scope.yfkdfhbol=true;
                                   $scope.yifahuobol=false;
                                   $scope.yidaohuobol=false;
                                   $scope.wanchengbol=false;
                                   $scope.yiquxiaobol=false;
                                   $scope.weifukuanbol=false;
                                     var record_code=$scope.data.record_code;
                                     //提醒发货
                                     // $scope.remind=function(code){
                                     //     var params = {};
                                     //     params.method = "order.send.remind";
                                     //     var p_params = {
                                     //         code:code,
                                     //     };
                                     //     params.params = JSON.stringify(p_params);
                                     //     $http.get(baison.get_url('api/', params)).success(function (data) {
                                     //         alert(data.message)
                                     //     })
                                     // };
                                 }else if($scope.data.status_name == "未付款"){
                                   $scope.yfkdfhbol=false;
                                   $scope.yifahuobol=false;
                                   $scope.yidaohuobol=false;
                                   $scope.wanchengbol=false;
                                   $scope.yiquxiaobol=false;
                                   $scope.weifukuanbol=true;
                                 }else if($scope.data.status_name == "已取消"){
                                   $scope.weifukuanbol=false;
                                   $scope.yfkdfhbol=false;
                                   $scope.yifahuobol=false;
                                   $scope.yidaohuobol=false;
                                   $scope.wanchengbol=false;
                                   $scope.yiquxiaobol=true;
                                 }else if($scope.data.status_name == "已发货"){
                                   $scope.weifukuanbol=false;
                                   $scope.yfkdfhbol=false;
                                   $scope.yifahuobol=true;
                                   $scope.yidaohuobol=false;
                                   $scope.wanchengbol=false;
                                   $scope.yiquxiaobol=false;
                                 }else if($scope.data.status_name == "已完成"){
                                   $scope.weifukuanbol=false;
                                   $scope.yfkdfhbol=false;
                                   $scope.yifahuobol=false;
                                   $scope.yidaohuobol=false;
                                   $scope.wanchengbol=true;
                                   $scope.yiquxiaobol=false;
                                 }
                                //  $scope.$apply();
                                  //  $scope.data = data.data.order_list;
                                  //  btnxianshi();
                                  //  //.log("$scope.data1");
                               } else {
                                  //  alert(data.message);
                               }
                           });
                     } else {
                        //  alert(data.message);
                     }
                 });}}
           };
           $scope.lijizhifu=function($event){
             var dataol = $scope.data;
            //  var zhifuindex = $($event.target).parents(".wddd_section-box").index();
             var iddata = $scope.data.platform_record_id;
             if($scope.data.pay_type == 28){
               $scope.submit_type = "button";
             }else if($scope.data.pay_type == 20){
                 var params = {};
                 params.method = "order.is.weixin";
                 $http.get(baison.get_url('api/', params))
                     .success(function(data) {
                         if (1 == data.status) {
                             $scope.submit_type = "weixin";
                         } else {
                             alert("请在微信环境中点击支付");
                             return;
                         }
                     });
             }else if ($scope.data.pay_type == 3) {
               $scope.submit_type = "alipay";
             }
             var params = {};
             params.method = "order.pay";
             params.id = iddata;
             params.trade_type_code = "allinpay";
             params.platform_type = 6;
             params.submit_type = $scope.submit_type;
             $http.get(baison.get_url('api/', params))
                 .success(function(data) {
                     if (data.status == 1) {
                         $scope.data2 = data;
                         if(dataol.pay_type == 28){
                             $openapp.openpay(iddata, function () {
                                //回调只有Android有效 移出
                             });
                             $timeout(function() {
                                 $state.go("zhiFuZhongJianYe",{
                                     id: "alipay",
                                     oid: ""
                                 });
                             }, 500);
                         }else if (dataol.pay_type == 3) {
                           button_type = "alipay";
                           $openapp.open(button_type,data.outpay_button,function(){
                                //回调只有Android有效 移出
                           });
                             $timeout(function() {
                                 $state.go("zhiFuZhongJianYe",{
                                     id: $scope.submit_type,
                                     oid: ""
                                 });
                             }, 500);
                         }else if (dataol.pay_type == 20) {
                           button_type = "weixin";
                           $openapp.open(button_type,data.outpay_button,function(){
                                //回调只有Android有效 移出
                           });
                             localStorage.setItem('weixin_pay_url', angular.toJson({
                                 url: data.outpay_button
                             }));
                             $state.go("zhiFuZhongJianYe",{
                                 id: $scope.submit_type,
                                 oid: ""
                             });
                         }
                     } else {
                         alert(data.message + "a");
                     }
                 });
           };
           $scope.pingjiatiaozhuan=function(order_id){
            //  var dataol = $scope.data;
            // //  var zhifuindex = $($event.target).parents(".wddd_section-box").index();
            //  var iddata = $scope.data.platform_record_id;
            //  for(var i =0;i<data.data.order_list.length;i++){
            //    if(iddata == data.data.order_list[i].platform_record_id){
                 localStorage.setItem('order_id',angular.toJson({data:order_id}));
                 $state.go('shangPinpPingJia');
            //    }
             //
            //  }
           };
           $scope.shenqingtuikuan=function(order_id){
            //  var dataol = $scope.data;
            // //  var zhifuindex = $($event.target).parents(".wddd_section-box").index();
            //  var iddata = $scope.data.platform_record_id;
            //  for(var i =0;i<data.data.order_list.length;i++){
            //    if(iddata == data.data.order_list[i].platform_record_id){
                 localStorage.setItem('order_id',angular.toJson({data:order_id}));
                 $state.go('shenQingTuiKuanList');
            //    }
             //
            //  }
           };
           $scope.querenshouhuo=function($event){
            //  var quxiaoindex = $($event.target).parents(".wddd_section-box").index();
             var oids = $scope.data.record_code;
             var p_params = {};
             params.method = "order.confirm.order";
             p_params.id=oids;
             params.params = JSON.stringify(p_params);
             $http.get(baison.get_url('api/', params))
                 .success(function (data) {
                     if (data.status == 1) {
                       var params = {};
                       params.method = "order.list.order";
                       $http.get(baison.get_url('api/', params))
                           .success(function (data) {
                               if (data.status == 1) {
                                   $scope.data = data.data.order_list;
                                   btnxianshi();
                               } else {
                                  //  alert(data.message);
                               }
                           });
                     } else {
                        //  alert(data.message);
                     }
                 });
           }
         } else {
            //  //.log(data.message);
         }
     });
     // var addrid;
     // var params = {};
     // params.method = "member.list.address";
     // //p_params = {};
     // //params.params = JSON.stringify(p_params);
     // $http.get(baison.get_url('api/', params))
     //     .success(function(data) {
     //         if (data.status == 1) {
     //             $scope.addrdata = data.data;
     //             if (typeof($scope.addrdata[0]) != "undefined") {
     //                 addrid = $scope.addrdata[0].address_id;
     //             } else {
     //                 addrid = "";
     //             }

     //            //  //.log($scope.addrdata)
     //         } else {
     //            //  alert(data.message);
     //         }
     //     });
}])
// 门店指引kd控制器
.controller('mdzykdtCtrl',['$scope','$http','$state', function($scope,$http,$state) {

}])
// 门店指引打开地图控制器
.controller('mdzyOpenMapCtrl',['$scope','$http','$state', function($scope,$http,$state) {
  // $scope.searchtext={
  //   text:""
  // };
  // $scope.disbol=true;
  // $scope.searchmd = function(){
  //   //.log($scope.searchtext.text);
  //   var searchtext = $scope.searchtext.text;
  //   var params = {};
  //   params.method = "member.store";
  //   var p_params = {
  //       region_name:searchtext
  //   };
  //   params.params = JSON.stringify(p_params);
  //   //.log(params.params);
  //   $http.get(baison.get_url('api/', params))
  //      .success(function (data) {
  //          if (data.status == 1) {
  //            $scope.addrdata = data.data.stores;
  //            $scope.addrsize = data.data.stores.length;
  //            $scope.disbol=false;
  //              //.log(data.data);
  //          } else {
  //              alert(data.message);
  //          }
  //      });
  // }


}])
// 门店指引打开地图控制器
.controller('tuiKuanShenQingCtrl',['$scope','$http','$state','$stateParams','$interval', function($scope,$http,$state,$stateParams,$interval) {
    var goods_id = $stateParams.id;
    $scope.kuaidi={
        danhao:""
    }
    $scope.express={
        code:""
    }
    var params = {};
    params.method = "refund.order.refund";
    var p_params = {
        return_id:goods_id
    };
    params.params = JSON.stringify(p_params);
    $http.get(baison.get_url('api/', params))
        .success(function(data) {
            $scope.data = data.data;
            // 调试
            // $scope.data.refund_type = 2;
            // $scope.data.sid = '10086';
            // $scope.data.company_name = 'hhh';
            // refund.apply.express
            // $scope.data.status = 20;
            // $scope.data.status_name = '不通过';
            $scope.kuaidi.danhao = $scope.data.sid;

            //var refund_allday = 7; // 售后有效时间
            //var refund_time = refund_allday *24*60*60 - $scope.data.countdown;
            var refund_time = $scope.data.countdown;

            if($scope.data.countdown && $scope.data.refund_type==2){
                var timer = $interval(function(){
                    if(refund_time <= 0){
                        $interval.cancel(timer);
                    }
                    var sum_time = refund_time;
                    if(parseInt(sum_time/(1*24*60*60)) > 0){
                        $scope.data.refund_day = parseInt(refund_time/(1*24*60*60));
                        sum_time = sum_time % (1*24*60*60);
                        if(parseInt(sum_time/(1*60*60)) > 0){
                            var refund_hour = parseInt(sum_time/(1*60*60));
                            if(refund_hour < 10){
                                $scope.data.refund_hour = '0';
                            }else{
                                $scope.data.refund_hour = '';
                            }
                            $scope.data.refund_hour += refund_hour;
                            sum_time = sum_time % (1*60*60);
                            if(parseInt(sum_time/(1*60)) > 0){
                                var refund_minute = parseInt(sum_time/(1*60));
                                if(refund_minute < 10){
                                    $scope.data.refund_minute = '0';
                                }else{
                                    $scope.data.refund_minute = '';
                                }
                                $scope.data.refund_minute += refund_minute;
                            }else{
                                $scope.data.refund_minute = '00';
                            }
                        }else{
                            $scope.data.refund_hour = '00';
                        }
                    }else{
                        $scope.data.refund_day = '0';
                    }
                    refund_time--;
                },1000);
            }

            $scope.tijiao=function(){
                var params = {};
                params.method = "refund.apply.express";
                var p_params = {
                    return_id:$scope.data.return_apply_id,
                    sid:$scope.kuaidi.danhao,
                    company_code:$scope.express.code
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if(data.status==1){
                            // $scope.data = data.data;
                            location.reload();
                        }else{
                            alert(data.message);
                        }
                });
            };

            $scope.tiaozhuan = function(order){
                localStorage.setItem('order_id', angular.toJson({
                    data: order.record_id
                }));
                localStorage.setItem('detail_id', angular.toJson({
                    data: order.record_detail_id
                }));
                localStorage.setItem('refundType', angular.toJson({
                    data: $scope.data.refund_type
                }));
                $state.go('tuiKuanWeiDaoHuo');
            }

    });
}])
// 修改密码控制器
.controller('xiuGaiMiMaCtrl',['$scope','$http','$state', function($scope,$http,$state) {

        $scope.password = {kw:''};//接收用户原密码
        $scope.newPassword = {kw:''};//接收用户新密码
        $scope.rePassword = {kw:''};//用户确认新密码

        //原密码睁开眼显示内容
        $scope.eyePasswordState = false;
        $scope.eyePasswordOpen = function(){
            $scope.eyePasswordState = !$scope.eyePasswordState;
            var pwdText1 = document.getElementById('pwdText1');
            if($scope.eyePasswordState){
                pwdText1.setAttribute('type','text');
            }else{
                pwdText1.setAttribute('type','password');
            }
        };

        //新密码睁开眼显示内容
        $scope.newPasswordState = false;
        $scope.newPasswordOpen = function(){
            $scope.newPasswordState = !$scope.newPasswordState;
            var newPsd = document.getElementById('newPsd');
            if($scope.newPasswordState){
                newPsd.setAttribute('type','text');
            }else{
                newPsd.setAttribute('type','password');
            }
        };
        //确认密码睁开眼显示内容
        $scope.rePasswordState = false;
        $scope.rePasswordOpen = function(){
            $scope.rePasswordState = !$scope.rePasswordState;
            var rePsd1 = document.getElementById('rePsd1');
            if($scope.rePasswordState){
                rePsd1.setAttribute('type','text');
            }else{
                rePsd1.setAttribute('type','password');
            }
        };
        $scope.checkChong = function(){
          if($scope.newPassword.kw != $scope.rePassword.kw){
              alert('密码不一致');
          }else{
              return true;
          }
        };

        $scope.xiuPsdSubmit = function(){
                var params = {};
                params.method = "member.edit.password";
                var p_params = {
                    password: $scope.password.kw,
                    new_password:$scope.newPassword.kw,
                    re_password:$scope.rePassword.kw
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function (data) {
                        if (data.status == 1) {
                             alert('修改密码成功');
                            $state.go('xiuGaiGeRenShuXing');
                        } else {
                            alert('密码错误');
                        }
                    });
            }
}])

// 个人中心控制器
.controller('geRenZhongXinCtrl',['$rootScope','$scope','$http','$state','$bMap','$httpRequest','$ntkf','$baidulocation', function($rootScope,$scope,$http,$state,$bMap,$httpRequest,$ntkf,$baidulocation) {

    //调用小能客服
    $ntkf.init();

    $scope.userInfo = function(data){
        if (data.status == 1) {
            $scope.data = data.data;
            if(!$scope.data.headimgurl){
                $scope.data.imgUrlShow = true;
            }else{
                $scope.data.imgUrlShow = false;
            }

            //百度地图定位
            $baidulocation.location(function(data){
                $scope.data.baidulocation = data.all;
                $scope.$apply();
            });
        } else {
            //  console.log(data.message);
        }
    };
    $httpRequest.getResult("member.get.info",{},$scope.userInfo);

    $scope.showFooterC = true;
    var login_name = angular.fromJson(localStorage.getItem('loginName'));
    if(!login_name){
        $rootScope.notLoginMark();
    }
    $scope.dingdan=function(id){
        if(id == 0){
            localStorage.setItem('order_tab',angular.toJson({data:"order_all"}));
            $state.go('woDeDingDan');
        }else if(id == 1){
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_pay"}));
            $state.go('woDeDingDan');
        }else if(id == 2){
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_delivery"}));
            $state.go('woDeDingDan');
        }else if(id == 3){
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_task_delivery"}));
            $state.go('woDeDingDan');
        }else if(id == 4){
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_assess"}));
            $state.go('woDeDingDan');
        }else{
            $state.go('shouHouZhuangTaiList');
        }
    };
    $scope.personalCenter = {
        //控制跳转
        goXiuSku:function(){
            if(login_name){
                $state.go('xiuGaiGeRenShuXing');
            }else{
                $rootScope.notLoginMark();
            }
        }
    }
}])
// 我的订单控制器
.controller('woDeDingDanCtrl',['$scope','$http','$state','$openapp','$httpRequest','$ntkf','$orderStatusDisplay','$timeout', function($scope,$http,$state,$openapp,$httpRequest,$ntkf,$orderStatusDisplay,$timeout) {
    //调用小能客服
    $ntkf.init();

    $scope.nav_go = function(path){
        if( 'all' == path ){
            $scope.orderShow('order_all');
            localStorage.setItem('order_tab',angular.toJson({data:"order_all"}));
        }else if( 'no_pay' == path ){
            $scope.orderShow('order_no_pay');
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_pay"}));
        }else if( 'no_delivery' == path ){
            $scope.orderShow('order_no_delivery');
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_delivery"}));
        }else if( 'no_task_delivery' == path ){
            $scope.orderShow('order_no_task_delivery');
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_task_delivery"}));
        }else if( 'no_assess' == path ){
            $scope.orderShow('order_no_assess');
            localStorage.setItem('order_tab',angular.toJson({data:"order_no_assess"}));
        }else{
            $scope.orderShow('order_all');
            localStorage.setItem('order_tab',angular.toJson({data:"order_all"}));
        }
    };

    $scope.backgo=function(){
        $state.go('geRenZhongXin')
    };
    $scope.tiaozhuan=function(k){
        $state.go('dingDanXiangQing',{
            id:k
        })
    };

    $scope.orderShow = function(order_tab){
        var params = {};

        if(!order_tab){
            order_tab = angular.fromJson(localStorage.getItem('order_tab')).data;
        }

        if('order_no_pay' == order_tab){
            params.status = 'no_pay';
            $scope.all_activebol = false;
            $scope.nopay_activebol = true;
            $scope.nodelivery_activebol = false;
            $scope.notaskdelivery_activebol = false;
            $scope.noassess_activebol = false;
        }else if('order_no_delivery' == order_tab){
            params.status = 'no_delivery';
            $scope.all_activebol = false;
            $scope.nopay_activebol = false;
            $scope.nodelivery_activebol = true;
            $scope.notaskdelivery_activebol = false;
            $scope.noassess_activebol = false;
        }else if('order_no_task_delivery' == order_tab){
            params.status = 'no_task_delivery';
            $scope.all_activebol = false;
            $scope.nopay_activebol = false;
            $scope.nodelivery_activebol = false;
            $scope.notaskdelivery_activebol = true;
            $scope.noassess_activebol = false;
        }else if('order_no_assess' == order_tab){
            params.status = 'no_assess';
            $scope.all_activebol = false;
            $scope.nopay_activebol = false;
            $scope.nodelivery_activebol = false;
            $scope.notaskdelivery_activebol = false;
            $scope.noassess_activebol = true;
        }else{
            $scope.all_activebol = true;
            $scope.nopay_activebol = false;
            $scope.nodelivery_activebol = false;
            $scope.notaskdelivery_activebol = false;
            $scope.noassess_activebol = false;
        }
        $httpRequest.getResult("order.list.order",params,$scope.orderShowAfter);
    };

    $scope.orderShowAfter = function(data) {
        if (data.status == 1) {
            if (data.data.order_list.length > 0) {
                $orderStatusDisplay.display(data.data.order_list,
                    function (data) {
                        $scope.data = data;
                        $scope.disbol = false;
                    });
            }else{
                $scope.disbol = true;
            }
        }
    };
    $scope.orderShow();

    //提醒发货
    $scope.remind=function(record_code){
        $httpRequest.getResult("order.send.remind", {
            'code':record_code
        }, function (data) {
            alert(data.message);
        });
    };

    $scope.cannelOrder = function($event,record_code){
        var tfbol = "";
        var eve = $event;
        $(".gwc_zzc_queren").toggleClass("disnone");

        $scope.record_code = record_code;
        $scope.cannelOrderAfter = function(data){
            if(data.status == 1){
                $scope.orderShow(angular.fromJson(localStorage.getItem('order_tab')));
            }
        };

        $scope.tfselect = function($event) {
            if ($($event.target).attr("class") == "gwc_zzc_confirm") {
                tfbol = true;
            } else if ($($event.target).attr("class") != "gwc_zzc_confirm") {
                tfbol = false;
            }
            $(".gwc_zzc_queren").toggleClass("disnone");
            if (tfbol) {
                $httpRequest.getResultNoParams("order.cancel.order", {'oid': $scope.record_code}, $scope.cannelOrderAfter);
            }
        }
    };

    $scope.wuliu = function(express_code,express_no,express_name){
        localStorage.setItem('express',angular.toJson({
            express_code:express_code,
            express_no:express_no,
            express_name:express_name
        }));
        $state.go("wuLiuXinXi");
    };

    $scope.pingjiatiaozhuan=function(order_id){
        localStorage.setItem('order_id',angular.toJson({data:order_id}));
        $state.go('shangPinpPingJia');
    };

    $scope.shenqingtuikuan=function(order_id){
        localStorage.setItem('order_id',angular.toJson({data:order_id}));
        $state.go('shenQingTuiKuanList');
    };

    $scope.lijizhifu=function(platform_record_id,pay_type){
        if(pay_type == 28){
            submit_type = "button";
        }else if(pay_type == 20){
            var params = {};
            params.method = "order.is.weixin";
            $http.get(baison.get_url('api/', params))
                .success(function(data) {
                    if (1 == data.status) {
                        submit_type = "weixin";
                    } else {
                        alert("请在微信环境中点击支付");
                        return;
                    }
                });
        }else if (pay_type == 3) {
            submit_type = "alipay";
        }

        $scope.orderPayAfter = function(data){
            if (data.status == 1) {
                $scope.data2 = data;
                if(pay_type == 28){
                    $openapp.openpay(platform_record_id, function () {
                        //回调只有Android有效 移出
                    });
                    $timeout(function() {
                        $state.go("zhiFuZhongJianYe",{
                            id: "alipay",
                            oid: ""
                        });
                    }, 500);
                }else if (pay_type == 3) {
                    $openapp.open(submit_type,data.outpay_button,function(){
                        //回调只有Android有效 移出
                    });
                    $timeout(function() {
                        $state.go("zhiFuZhongJianYe",{
                            id: submit_type,
                            oid: ""
                        });
                    }, 500);
                }else if (pay_type == 20) {
                    $openapp.open(submit_type,data.outpay_button,function(){
                        //回调只有Android有效 移出
                    });
                    localStorage.setItem('weixin_pay_url', angular.toJson({
                        url: data.outpay_button
                    }));
                    $state.go("zhiFuZhongJianYe",{
                        id: submit_type,
                        oid: ""
                    });
                }
            } else {
                alert(data.message);
            }
        };
        $httpRequest.getResultNoParams("order.pay", {
            'id':platform_record_id,
            'trade_type_code':'allinpay',
            'platform_type':6,
            'submit_type':submit_type
        }, $scope.orderPayAfter);
    };

    $scope.querenshouhuo=function(platform_record_id){

        $scope.confirmOrderAfter = function(data){
            if (data.status == 1) {
                $scope.orderShow('order_no_assess');
            } else {
                alert(data.message);
            }
        };
        $httpRequest.getResult("order.confirm.order", {'id':platform_record_id}, $scope.confirmOrderAfter);
    }

}])
// 我的订单退款控制器
.controller('woDeDingDanTuiKuanCtrl',['$scope','$http','$state', function($scope,$http,$state) {

}])
.controller('shangPinPingJiaCtrl',['$scope','$http','$state','$httpRequest', function($scope,$http,$state,$httpRequest) {

    $scope.order_id = angular.fromJson(localStorage.getItem('order_id')).data;

    $httpRequest.getResult("order.trade.get", {'order_id':$scope.order_id}, function(data){
        if (data.code == 1) {
            $scope.data = data.data;
            $scope.pingjiatiaozhuan = function(order_id,order_detail_id) {
                localStorage.setItem('order_id', angular.toJson({
                    data: order_id
                }));
                localStorage.setItem('order_detail_id', angular.toJson({
                    data: order_detail_id
                }));
                $state.go("woDeDingDanPingJia");
            }
        } else {
            //  console.log(data.message);
        }
    });
}])
// 我的订单评价控制器
.controller('woDeDingDanPingJiaCtrl',['$scope','$http','$state','$zhaopianSelect','$httpRequest','$imgupload', function($scope,$http,$state,$zhaopianSelect,$httpRequest,$imgupload) {

    $scope.order_id = angular.fromJson(localStorage.getItem('order_id')).data;
    $scope.order_detail_id = angular.fromJson(localStorage.getItem('order_detail_id')).data;
    $scope.tuikuan={
        shuoming:""
    };
    var tuikuanimg = [];
    //减掉图
    $scope.add_img_ov=true;
    $scope.add_img=false;
    $scope.jianshao=function(index){
        tuikuanimg.splice(index,1);
        $scope.imgList=tuikuanimg;
        if(tuikuanimg.length<5&&tuikuanimg.length>0){
            $scope.add_img=true;
        }else if(tuikuanimg.length==0){
            $scope.add_img=false;
            $scope.add_img_ov=true;
        }
    };

    $httpRequest.getResult("order.trade.get", {
            'order_id': $scope.order_id,
            'detail_id': $scope.order_detail_id
        }, function(data){
            if (data.code == 1) {
                $scope.data = data.data;
                $scope.tuikuandata = data.data.detail[0];
            }}
    );

    var voucher1 = "";
    var voucher2 = "";
    var voucher3 = "";
    var voucher4 = "";
    var voucher5 = "";

    $scope.tijiaopingjia=function(){
        if(tuikuanimg[0]!=undefined){
            voucher1 = tuikuanimg[0];
        }
        if(tuikuanimg[1]!=undefined){
            voucher2 = tuikuanimg[1];
        }
        if(tuikuanimg[2]!=undefined){
            voucher3 = tuikuanimg[2];
        }
        if(tuikuanimg[3]!=undefined){
            voucher4 = tuikuanimg[3];
        }
        if(tuikuanimg[4]!=undefined){
            voucher5 = tuikuanimg[4];
        }

        $httpRequest.getResult("order.comment.item", {
                'goods_code': $scope.tuikuandata.goods_code,
                //'record_code': $scope.tuikuandata.record_code,
                'platform_type': 6,
                'detail_id': $scope.order_detail_id,
                'remark': $scope.tuikuan.shuoming,
                'voucher_pic1': voucher1,
                'voucher_pic2': voucher2,
                'voucher_pic3': voucher3,
                'voucher_pic4': voucher4,
                'voucher_pic5': voucher5
            }, function(data){
                if (data.status == 1) {
                    $state.go("woDeDingDan");
                }else{
                    alert(data.message);
                    return;
                }}
        );
    };

    $scope.zhaopian = function(files){
        $zhaopianSelect.zpslt(files,function(ret){
            $imgupload.chageimg(ret,{
                'method':"refund.upload.img",
                'id':$scope.tuikuandata.platform_record_detail_id,
            },function(data){
                if(data.data == undefined){
                    $(".gwc_zzc_queren").toggleClass("disnone");
                    alert("图片过大请重新上传,图片大小不能超过2M");
                }else{
                    if(tuikuanimg.length<5){
                        tuikuanimg.push(data.data.img);
                        $scope.imgList= tuikuanimg;
                        $scope.add_img_ov=false;
                        $scope.add_img=true;
                        if(tuikuanimg.length>=5){
                            $scope.add_img=false;
                        }
                        //.log(JSON.stringify(tuikuanimg));
                        //for(var i = 0;i<tuikuanimg.length;i++){
                        //  $(".voucher").eq(i).attr("src",tuikuanimg[i]);
                        //  //.log(tuikuanimg[i]);
                        //}
                        $(".gwc_zzc_queren").toggleClass("disnone");
                    }else{
                        alert("图片上传最多5张");
                        $(".gwc_zzc_queren").toggleClass("disnone");
                    }
                }
            });
        });
    }

}])
// 修改手机旧控制器
    .controller('xiuGaiShouJiOldCtrl',['$scope','$http','$state','$httpRequest', function($scope,$http,$state,$httpRequest) {

        $scope.psd = {kw:''};
        var oldPhone = angular.fromJson(localStorage.getItem('loginName'));
        $scope.oldPhone = oldPhone.username;
        $scope.showTanChuang = false;
        //if(){}
        $scope.showTanChuang = true;

        $scope.checkPhone = function(){

            $httpRequest.getResult("member.check.password", {
                    'password': $scope.psd.kw
                }, function(data){
                    if (data.status == 1) {
                        $state.go('xiuGaiShouJiNew');
                    } else {
                        alert('密码错误');
                    }}
            );

        }

    }])
// 修改手机新控制器
    .controller('xiuGaiShouJiNewCtrl',['$scope','$http','$state','$interval', function($scope,$http,$state,$interval) {
        $scope.phone = {kw:''};//手机号码
        $scope.registerTime = 60;//倒计时
        $scope.showYanZhengMa = true;//控制验证码显示与隐藏
        $scope.yanZheng = {kw:''};//验证码
        $scope.icon1 = false;//控制对与错图标
        var pattern = /^1\d{10}$/;//验证手机号
        //检测用户是否存在接口调用
        $scope.checkUser = function(){
            if(pattern.test($scope.phone.kw)){
                var params = {};
                params.method = "member.check.vip";
                var p_params = {
                    mobile:$scope.phone.kw
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if (data.status == 1) {
                            //alert(data.message);
                            $scope.checkVipStatus = data.status;
                        } else if(data.status == '-1'){
                            alert('手机已存在');
                        }
                    });
            }else{
                alert( '请输入正确的手机');
            }
        };

        //验证接口调用
        $scope.yan = function(){
            if(pattern.test($scope.phone.kw) && $scope.checkVipStatus == 1){
                $scope.showYanZhengMa = !$scope.showYanZhengMa;
                var time1 = $interval(function(){
                    $scope.registerTime--;
                    if($scope.registerTime==0){
                        $scope.showYanZhengMa = !$scope.showYanZhengMa;
                        $interval.cancel(time1);
                        $scope.registerTime = 60;
                    }
                },1000);
                var params = {};
                params.method = "member.get.yan";
                var p_params = {
                    mobile:$scope.phone.kw
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if (data.status == 1) {

                        }
                    });
            }
         //var time2 =  $interval(function(){
         //      if(pattern.test($scope.phone.kw) && $scope.checkVipStatus == 1){
         //          $interval.cancel(time2);
         //          $scope.showYanZhengMa = !$scope.showYanZhengMa;
         //          var time1 = $interval(function(){
         //              $scope.registerTime--;
         //              if($scope.registerTime==0){
         //                  $scope.showYanZhengMa = !$scope.showYanZhengMa;
         //                  $interval.cancel(time1);
         //                  $scope.registerTime = 60;
         //              }
         //          },1000);
         //          var params = {};
         //          params.method = "member.get.yan";
         //          var p_params = {
         //              mobile:$scope.phone.kw
         //          };
         //          params.params = JSON.stringify(p_params);
         //          $http.get(baison.get_url('api/', params))
         //              .success(function(data) {
         //                  if (data.status == 1) {
         //                      var time1 = $interval(function(){
         //                          if($scope.yanZheng.kw == data.data.slice(0,4)){
         //                              $scope.icon1 = true;
         //                              $interval.cancel(time1);
         //                          }else{
         //                              $scope.icon1 = false;
         //                          }
         //                      },1000);
         //                  }
         //              });
         //      }
         //  },500);
        };

        //调用修改手机接口
        $scope.xiuNext = function(){
            var params = {};
            params.method = "member.edit.mobile";
            var p_params = {
                mobile:$scope.phone.kw,
                yan:$scope.yanZheng.kw
            };
            params.params = JSON.stringify(p_params);
            $http.get(baison.get_url('api/', params))
                .success(function(data) {
                    if (data.status == 1) {
                        localStorage.removeItem('loginName');
                        localStorage.setItem('loginName',angular.toJson({username:$scope.phone.kw}));

                        // alert(data.message);
                        $state.go('xiuGaiGeRenShuXing');
                    } else {
                        alert(data.message);
                    }
                });
        }
    }])

// 修改个人属性控制器
    .controller('xiuGaiGeRenShuXingCtrl',['$scope','$http','$state','$riqiSelect','$zhaopianSelect','$httpRequest','$imgupload', function($scope,$http,$state,$riqiSelect,$zhaopianSelect,$httpRequest,$imgupload) {

        // $scope.reader = new FileReader();
        var date1 = new Date();
        var year = date1.getFullYear();
        var month = date1.getMonth()+1;
        var dateri = date1.getDate();

        $scope.settings = {
            theme: "mobiscroll",// 设置主题风格
            display: 'bottom', //显示方式
            mode: 'scroller', //日期选择模式
            dateFormat: 'yy-mm-dd',
            lang: 'zh',
            //startYear: (new Date()).getFullYear() - 50, //开始年份
            defaultValue:new Date('1989','00','01'),
            //endYear: (new Date()).getFullYear(), // 设置结束年份 默认为明年 下设置了max 此endYear不起作用
            //min: new Date('2016','08','10'),// 设置开始日期
            max: new Date(year,month,dateri),// 设置结束日期
            onSet: function (event, inst) {
                $scope.geRenSku.showRiQi(inst._value);
                // Your custom event handler goes here
            }
        };

        $scope.chageimg = function(files){
            $zhaopianSelect.zpslt(files,function(ret){
                $imgupload.chageimg(ret,{
                    'method':"member.upload.img",
                },function(data){
                    if(data.status ==1){

                        $httpRequest.getResult("member.edit.headimg", {
                            'headimgurl':data.data.img,
                        }, function(data){
                            if (data.status == 1) {
                                //console.log(data.data);
                            } else {
                                alert('修改失败');
                            }
                        });
                    }else{
                    }
                });
            });
        }

        $scope.gaiNickName = {kw:''};//修改昵称
        $scope.sex = {kw:''};//修改性别
        $scope.imgUrlShow = false;
        //调取获取用户信息接口

        $httpRequest.getResult("member.get.info", {}, function(data){
            if (data.status == 1) {
                $scope.data = data.data;
                $scope.imgUrl = $scope.data.headimgurl;
                if(!$scope.imgUrl){
                    $scope.imgUrlShow = true;
                }else{
                    $scope.imgUrlShow = false;
                }
                localStorage.setItem('loginName',angular.toJson({username:$scope.data.mobile}));
                $scope.chuan=function(){
                    localStorage.setItem('nicheng',angular.toJson({name:$scope.data.nickname}));
                };
                if($scope.data.sex == 1){
                    $scope.data.sex = '男';
                }else if($scope.data.sex == 2){
                    $scope.data.sex = '女';
                }
            } else {
                alert('修改失败');
            }
        });

        $scope.geRenSku = {
            dialong:false,//控制模态框
            input:false,//控制昵称输入框
            radio:false,//控制性别单选框
            showDialong:function(){
                this.dialong = !this.dialong;
                this.input = !this.input;
            },
            showRadio:function(){
                this.dialong = !this.dialong;
                this.radio = !this.radio;
            },
            checkSex:function($event){
                var sex = $event.target.innerHTML;
                var sexLast = '';
                if(sex == '男'){
                    sexLast = 1;
                }else if(sex == '女'){
                    sexLast = 2;
                }

                $httpRequest.getResult("member.edit.sex", {
                    'sex':sexLast
                }, function(data){
                    if (data.status == 1) {

                        $httpRequest.getResult("member.get.info", {}, function(data){
                            if (data.status == 1) {
                                // $scope.data = "";
                                $scope.data = data.data;
                                if($scope.data.sex == 1){
                                    $scope.data.sex = '男';
                                }else if($scope.data.sex == 2){
                                    $scope.data.sex = '女';
                                }
                            } else {
                                alert(data.message);
                            }
                        });

                        $scope.geRenSku.dialong = !$scope.geRenSku.dialong;
                        $scope.geRenSku.input = !$scope.geRenSku.input;
                    } else {
                        alert(data.message);
                    }
                });

            },
            showRiQi:function(date){

                $httpRequest.getResult("member.edit.birthday", {
                    'birthday':date
                }, function(data){
                    if (data.status == 1) {

                        $httpRequest.getResult("member.get.info", {}, function(data){
                            if (data.status == 1) {
                                // $scope.data = "";
                                $scope.data = data.data;
                                if($scope.data.sex == 1){
                                    $scope.data.sex = '男';
                                }else if($scope.data.sex == 2){
                                    $scope.data.sex = '女';
                                }
                            } else {
                                alert(data.message);
                            }
                        });

                    } else {
                        alert(data.message);
                    }
                });
            },

            //退出登录
            logout:function(){

                $httpRequest.getResult("member.logout", {}, function(data){
                    if (data.status == 1) {
                        localStorage.removeItem('loginName');
                        alert('退出成功');
                        $state.go('pinPaiQuan');
                    } else {
                        alert(data.message);
                    }
                });

            }
        }

    }])

// 修改个人属性昵称控制器;
    .controller('xiuGaiGeRenNiChengCtrl',['$scope','$http','$state', function($scope,$http,$state) {
      var nicheng = angular.fromJson(localStorage.getItem('nicheng')).name;
       $scope.nickName = {kw:nicheng};
        $scope.clearName = function(){
            $scope.nickName.kw = '';
        };
       $scope.checkName = function(){
           var params = {};
           params.method = "member.edit.nickname";
           var p_params = {
               nickname:$scope.nickName.kw
           };
           params.params = JSON.stringify(p_params);
           $http.get(baison.get_url('api/', params))
           .success(function (data) {
               if (data.status == 1) {
                   // $state.go('xiuGaiGeRenShuXing');
                   history.back();
               } else {
                  alert(data.message);
               }
           });
       }
    }])

// 我的订单退款控制器;
    .controller('woDeDingDanTuiKuanCtrl',['$scope','$http','$state', function($scope,$http,$state) {

    }])

//喜欢控制器
    .controller('xiHuanCtrl',['$scope','$http','$state','$swipers','$httpRequest', function($scope,$http,$state,$swipers,$httpRequest) {

        // $scope.showKong = false;//显示空数据页面
        // $scope.tabShow = true;//控制切换
        //路由跳转
        $scope.toXiangQing = function(goods_id){
            $state.go('chanPinXiangQing',{
                id:goods_id
            })
        };

        $scope.tabShowControl = function(){
            $scope.tabShow = !$scope.tabShow;
        };

        $scope.repeatFinish = function(){
            $scope.swipers = $swipers.swp('.swiper-container',false,0,1,1,'.swiper-pagination','.swiper-button-prev','.swiper-button-next',0,false,function(){
                return;
            });
        };

        $scope.cancelLove = function(goods_code,key){

            var tfbol = "";

            $(".gwc_zzc_queren").toggleClass("disnone");

            $scope.tfselect = function($event) {

                if ($($event.target).attr("class") == "gwc_zzc_confirm") {
                    tfbol = true;
                } else if ($($event.target).attr("class") != "gwc_zzc_confirm") {
                    tfbol = false;
                }
                $(".gwc_zzc_queren").toggleClass("disnone");
                if (tfbol) {

                    $httpRequest.getResult("item.collect.goods",{
                        'goods_code':goods_code
                    },function(data){
                        if (data.status == 1) {
                            $scope.data.splice(key,1);
                            if($scope.data.length == 0){
                                $scope.tabShow = false;
                                $scope.showKong = true;
                            }
                        } else {
                            alert(data.message);
                        }
                    });

                }
            }

        };

        $httpRequest.getResult("member.get.collect.goods",{},function(data){
            if (data.status == 1) {
                $scope.data = data.data;

                $scope.gouwu=function($event){
                    var id = $($event.target).parents(".xihuan_padding_rl").attr("id");
                    localStorage.setItem('shopId',angular.toJson({data:id}));
                };
                $scope.showKong = false;
                $scope.tabShow = true;
            } else {
                $scope.showKong = true;
                $scope.tabShow = false;
            }
        });

    }])
    .controller('shenQingDaoKuanYiDaoHuoCtrl',['$scope','$http','$state', function($scope,$http,$state,$swipers) {

    }])
    .controller('wuLiuXinXiCtrl',['$scope','$http','$state', function($scope,$http,$state,$swipers) {
        $(function(){
            $scope.express_code = angular.fromJson(localStorage.getItem('express')).express_code;
            $scope.express_no = angular.fromJson(localStorage.getItem('express')).express_no;
            if ($scope.express_code != undefined && $scope.express_no != undefined) {
                var params = {};
                params.method = "member.get.logs";
                var p_params = {
                    //"LogisticCode":"824879090841",
                    //"ShipperCode":"SF"
                    "LogisticCode":$scope.express_code,
                    "ShipperCode":$scope.express_no
                };
                params.params = JSON.stringify(p_params);
                $http.get(baison.get_url('api/', params))
                    .success(function(data) {
                        if (data.status == 1) {
                            $scope.wuLiu = data.data;
                            $scope.wuLiu = $scope.wuLiu.reverse();
                        } else {
                            alert(data.message);
                        }
                    });
            } else {
                alert("该单号暂无物流进展，请稍后再试");
                history.back();
            }
        })
    }])
    .controller('huoDongTuiJianCtrl',['$scope','$http','$state', function($scope,$http,$state,$swipers) {

        var params = {};
        params.method = "article.list.activity";
        $http.get(baison.get_url('api/', params))
            .success(function(data) {
                $scope.data = data.data;
            });
            $scope.goto=function(id){
              $state.go("huoDongTuiJianYe",{id:id});
            };

        $scope.repeatFinish = function(){
        }
    }])
    .controller('shouHouFuWuCtrl',['$scope','$http','$state', function($scope,$http,$state,$swipers) {

        //控制服务内容开关
        var params = {};
        params.method = "item.get.service";
        $http.get(baison.get_url('api/', params))
            .success(function(data) {
                $scope.data = data.data;
                $('#showService').on('click','.shfw_li-list-box',function(){
                    if($(this).siblings('.shfw_wenzi_box').is(':hidden')){
                        $('.shfw_wenzi_box').hide();
                        $('img.shou-shang').removeClass('shang_icon');
                    }
                    $(this).siblings('.shfw_wenzi_box').toggle();
                    $(this).children('img.shou-shang').toggleClass('shang_icon');
                });
            });
        $scope.repeatFinish = function(){
            $('.shou-shang').addClass('shang_icon');
            $('.shfw_wenzi_box').hide();
        }
    }]);
//个人中心控制器模块    结束-----------------------------------------------------
